- 相關(guān)推薦
PHP面試題附答案
1. Which of the following will not add john to the users array?
1. $users[] = ‘john’;
2. array_add($users,’john’);
3. array_push($users,’john’);
4. $users ||= ‘john’;
Answer: 2,4
2. What’s the difference between sort(), asort() and ksort(),rsort()? Under what circumstances would you use each of these?
sort(): 本函數(shù)對(duì)數(shù)組的值進(jìn)行排序,
PHP面試題附答案
。當(dāng)本函數(shù)結(jié)束時(shí)數(shù)組單元將被從最低到最高重新安排,array 中的單元賦予新的鍵名。這將刪除原有的鍵名而不僅是重新排序。asort(): 這個(gè)函數(shù)將數(shù)組的值重新排序,由小至大排列。數(shù)組的索引亦跟著值的 順序而變動(dòng)。當(dāng)您在程序中需要重新整理數(shù)組值的 順序時(shí),就可以使用這個(gè)函數(shù)。
ksort(): 對(duì)數(shù)組按照鍵名排序,保留鍵名到數(shù)據(jù)的關(guān)聯(lián)。本函數(shù)主要用于關(guān)聯(lián)數(shù)組。
rsort(): 本函數(shù)對(duì)數(shù)組進(jìn)行逆向排序(最高到最低)。與sort()執(zhí)行相反的操作。
3. What would the following code print to the browser? Why?
$num = 10;
function multiply(){
$num = $num * 10;
}
multiply();
echo $num;
10
4. What is the difference between a reference and a regular variable? How do you pass by reference & why would you want to?
pass by reference like this functions(&$vars);
it likes more fast;
5. What functions can you use to add library code to the currently running script?
inlcude() or require();
6. What is the difference between foo() & @foo()?
if foo() throw a error, will be alert, but @foo() no;
7. How do you debug a PHP application?
xdebug or use die() do it;
8. What does === do? What’s an example of something that will give true for ‘==’, but not ‘===’?
=== 用于精確比較 ex: (” == null) => true but ( ”===null) =>false;
9. How would you declare a class named “myclass” with no methods or properties?
class myclass{
}
10. How would you create an object, which is an instance of “myclass”?
$myoject = new myclass();
11. How do you access and set properties of a class from within the class?
getVar() or setVar() ;
12. What is the difference between include & include_once? include & require?
require:PHP 程式在執(zhí)行前,就會(huì)先讀入 require 所指定引入的檔案,使它變成 PHP 程式網(wǎng)頁的一部份,
資料共享平臺(tái)
《PHP面試題附答案》(http://www.stanzs.com)。常用的函式,亦可以這個(gè)方法將它引入網(wǎng)頁中。錯(cuò)誤產(chǎn)生致命錯(cuò)誤。include:這個(gè)函式一般是放在流程控制的處理區(qū)段中。PHP 程式網(wǎng)頁在讀到 include 的檔案時(shí),才將它讀進(jìn)來。這種方式,可以把程式執(zhí)行時(shí)的流程簡單化。錯(cuò)誤產(chǎn)生警報(bào)。
include_once:此行為和include()語句類似,唯一區(qū)別是如果該文件中的代碼已經(jīng)被包含了,則不會(huì)再次包含。如同此語句名字暗示的那樣,只會(huì)包含一次。
13. What function would you use to redirect the browser to a new page?
1. redir()
【PHP面試題附答案】相關(guān)文章:
最新PHP筆試題目及答案05-25
銀行面試題目及答案09-19
益智成語猜謎附答案大全10-10
精彩元宵節(jié)燈謎附答案05-28
元宵燈謎大全附答案(成語篇)09-09
常見英文面試問題大全(附答案)06-20
元宵節(jié)地名類燈謎大全【附答案】09-15
會(huì)計(jì)類面試題(含答案)06-23
騰訊WEB前端筆試題和面試題答案10-09