php工程師面試問(wèn)題
1 .

請(qǐng)對(duì) POSIX 風(fēng)格和兼容 Perl 風(fēng)格兩種正則 表達(dá)式的主要函數(shù)進(jìn)行類比說(shuō)明
eregpreg_match
ereg_replacepreg_replace
2 .
請(qǐng)說(shuō)明在 php .ini 中 safe_mode 開(kāi)啟之后對(duì)于 PHP 系統(tǒng) 函數(shù)的影響
3 .
PHP5 中魔術(shù) 方法 函數(shù)有哪幾個(gè),請(qǐng)舉例說(shuō)明各自的用法
__sleep
__wakeup
__toString
__set_state
__construct,
__destruct
__call,
__get,
__set,
__isset,
__unset
__sleep,
__wakeup,
__toString,
__set_state,
__clone
__autoload
4 .
請(qǐng)寫出讓,并說(shuō)明如何在命令行下運(yùn)行 PHP 腳本(寫出兩種方式)同時(shí)向 PHP 腳本傳遞參數(shù)?
1.
Php filename.php $agr1 $agr2
2.
php –r “”
5 .
PHP 的垃圾收集機(jī)制是怎樣的
6 .使對(duì)象可以像數(shù)組一樣進(jìn)行 foreach 循環(huán),要求屬性必須是私有。
(Iterator 模式的 PHP5 實(shí)現(xiàn),寫一類實(shí)現(xiàn) Iterator 接口 )
7 .請(qǐng)寫一段 PHP 代碼 ,確保多個(gè)進(jìn)程同時(shí)寫入同一個(gè)文件 成功
8 .
用 PHP 實(shí)現(xiàn)一個(gè)雙向隊(duì)列
9 .
使用正則表達(dá)式提取一段標(biāo)識(shí)語(yǔ)言( html 或 xml )代碼段中指定標(biāo)簽的指定屬性值(需考慮屬性值對(duì)不規(guī)則的情況,如大小寫不敏感,屬性名值與等號(hào)間有 空格等)。此處假設(shè)需提取 test 標(biāo)簽的attr 屬性值,請(qǐng)自行構(gòu)建包含該標(biāo)簽的串
10 .請(qǐng)使用 socket 相關(guān)函數(shù)(非 curl )實(shí)現(xiàn)如下功 能:構(gòu)造一個(gè) post 請(qǐng)求,發(fā)送到指定 http server 的指定端口的指定請(qǐng)求路徑(如 http://www.example.com:8080/test )。請(qǐng)求中包含以下變量:
用戶名( username ):溫柔一刀
密碼( pwd ): &123=321&321=123&
個(gè)人簡(jiǎn)介( intro ): Hello world !
且該 http server 需要以下 cookie 來(lái)進(jìn)行簡(jiǎn) 單的用戶動(dòng)作跟蹤:
cur_query : you&me
last_tm : ... (上次請(qǐng)求的 unix 時(shí)間戳,定為當(dāng)前請(qǐng)求時(shí)間前 10 分鐘)
cur_tm : ... (當(dāng)前請(qǐng)求的 unix 時(shí)間戳)
設(shè)置超時(shí)為 10 秒,發(fā)出請(qǐng)求后, 將 http server 的響應(yīng)內(nèi)容輸出。
Function encode($data, $sep = ‘&’){
while (list($k,$v) = each($data)) {
$encoded .= ($encoded ? "$sep" : "");
$encoded .= rawurlencode($k)."=".rawurlencode($v);
}
Return $encoded;
}
Function post($url, $post, $cookie){
$url = parse_url($url);
$post = encode($data, ‘&’);
$cookie = encode($cookieArray, ‘;’);
$fp = fsockopen($url['host'], $url['port'] ? $url['port'] : 80,$errno,$errstr,10);
if (!$fp) return "Failed to open socket to $url[host]";
fputs($fp, sprintf("POST %s%s%s HTTP/1.0/n", $url['path'], $url['query'] ? "?" : "", $url['query']));
fputs($fp, "Host: $url[host]/n");
fputs($fp, "Content-type: application/x-www-form-urlencoded/n");
fputs($fp, "Content-length: " . strlen($encoded) . "/n");
fputs($fp, "Cookie: $cookie/n/n");
fputs($fp, "Connection: close/n/n");
fputs($fp, "$post /n");
while (!feof($fp)) {
echofgets($fp,128);
}
fclose($fp);
}
$url = ‘http://www.example.com:8080/test ’;
$encoded = username= 溫柔一刀 & pwd=
$post = array(
‘ username ’ => ‘溫柔一刀’ ,
‘ pwd => ‘&123=321&321=123&’,
‘ intro => ‘Hello world!’
);
$cookie = array(
‘ cur_query’ => ‘ you&me,
‘ last_tm’ =>time() -600,
‘cur_tm ‘=> time()
);
Post($url, $post, $cookie);
11 .你用什么方法檢查 PHP 腳本的執(zhí)行效率(通常是腳本執(zhí)行時(shí)間)和數(shù)據(jù)庫(kù) SQL 的效率(通常是數(shù)據(jù)庫(kù) Query 時(shí)間), 并定位和分析腳本執(zhí)行和數(shù)據(jù)庫(kù)查詢的瓶頸所在?
1 .腳本執(zhí)行時(shí)間,啟用 xdebug ,使用 WinCacheGrind 分析。
2 .數(shù)據(jù)庫(kù)查詢, mysql 使用 EXPLAIN 分析查詢,啟用 slow query log 記錄慢查詢。
[php工程師面試問(wèn)題]
【php工程師面試問(wèn)題】相關(guān)文章:
質(zhì)量工程師面試問(wèn)題09-14
質(zhì)量工程師面試問(wèn)題09-06
PHP面試題10-14
軟件工程師面試問(wèn)題09-14
機(jī)械工程師面試問(wèn)題10-05
運(yùn)維工程師面試問(wèn)題08-09
php工程師的就業(yè)前景08-14
網(wǎng)絡(luò)工程師面試常見(jiàn)問(wèn)題10-19
PHP面試題與答案07-22