日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

腾讯php开发工程师面试题

發(fā)布時間:2024/3/12 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 腾讯php开发工程师面试题 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1
請對 POSIX 風格和兼容 Perl 風格兩種正則 表達式的主要函數(shù)進行類比說明

ereg

preg_match

ereg_replace

preg_replace

2
請說明在 php .ini safe_mode 開啟之后對于 PHP 系統(tǒng) 函數(shù)的影響

3
PHP5 中魔術(shù) 方法 函數(shù)有哪幾個,請舉例說明各自的用法

__sleep

__wakeup

__toString

__set_state

__construct,

__destruct

__call,

__get,

__set,

__isset,

__unset

__sleep,

__wakeup,


__toString,


__set_state,

__clone


__autoload

4
請寫出讓,并說明如何在命令行下運行 PHP 腳本(寫出兩種方式)同時向 PHP 腳本傳遞參數(shù)?

1.
Php filename.php $agr1 $agr2

2.
php –r “<?php code?>”

5
PHP 的垃圾收集機制是怎樣的




6 .使對象可以像數(shù)組一樣進行 foreach 循環(huán),要求屬性必須是私有。

(Iterator 模式的 PHP5 實現(xiàn),寫一類實現(xiàn) Iterator 接口 )

7 .請寫一段 PHP 代碼 ,確保多個進程同時寫入同一個文件 成功

8
PHP 實現(xiàn)一個雙向隊列

9
使用正則表達式提取一段標識語言( html xml )代碼段中指定標簽的指定屬性值(需考慮屬性值對不規(guī)則的情況,如大小寫不敏感,屬性名值與等號間有 空格等)。此處假設(shè)需提取 test 標簽的 attr 屬性值,請自行構(gòu)建包含該標簽的串

<test attr=”ddd”>

<test attr/s*=/s*[“|’](.*?)[”|’].*?>

10 .請使用 socket 相關(guān)函數(shù)(非 curl )實現(xiàn)如下功 能:構(gòu)造一個 post 請求,發(fā)送到指定 http server 的指定端口的指定請求路徑(如 http://www.example.com:8080/test )。請求中包含以下變量:

用戶名( username ):溫柔一刀

密碼( pwd ): &123=321&321=123&

個人簡介( intro ): Hello world !

且該 http server 需要以下 cookie 來進行簡 單的用戶動作跟蹤:

cur_query you&me

last_tm ... (上次請求的 unix 時間戳,定為當前請求時間前 10 分鐘)

cur_tm ... (當前請求的 unix 時間戳)

設(shè)置超時為 10 秒,發(fā)出請求后, 將 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ù)據(jù)庫 SQL 的效率(通常是數(shù)據(jù)庫 Query 時間), 并定位和分析腳本執(zhí)行和數(shù)據(jù)庫查詢的瓶頸所在?

1 .腳本執(zhí)行時間,啟用 xdebug ,使用 WinCacheGrind 分析。

2 .數(shù)據(jù)庫查詢, mysql 使用 EXPLAIN 分析查詢,啟用 slow query log 記錄慢查詢。

總結(jié)

以上是生活随笔為你收集整理的腾讯php开发工程师面试题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。