Chinaunix

标题: PHP工程师笔试题汇总 [打印本页]

作者: lesson001    时间: 2011-01-27 21:16
标题: PHP工程师笔试题汇总
腾讯PHP工程师笔试题
腾讯PHP工程师笔试题.rar (2.89 KB, 下载次数: 1319)
新浪php工程师的面试题(编程部分)

Yahoo! PHP 笔试题



腾讯PHP工程师笔试题
1. 请对POSIX风格和兼容Perl风格两种正则表达式的主要函数进行类比说明
ereg preg_match
ereg_replace preg_replace


2. 请说明在php.ini中safe_mode开启之后对于PHP系统函数的影响


3. PHP5中魔术方法函数有哪几个,请举例说明各自的用法

__sleep
__wakeup
__toString
__set_state
__construct,
__destruct
__call,
__get,
__set,
__isset,
__unset
__sleep,
__wakeup,
__toString,
__set_state,
__clone
__autoload


4. 请写出让,并说明如何在命令行下运行PHP脚本(写出两种方式)同时向PHP脚本传递参数?


5. PHP的垃圾收集机制是怎样的


6.使对象可以像数组一样进行foreach循环,要求属性必须是私有。
(Iterator模式的PHP5实现,写一类实现Iterator接口)


7.请写一段PHP代码,确保多个进程同时写入同一个文件成功


8. 用PHP实现一个双向队列


9. 使用正则表达式提取一段标识语言(html或xml)代码段中指定标签的指定属性值(需考虑属性值对不规则的情况,如大小写不敏感,属性名值与等号间有空格等)。此处假设需提取test标签的attr属性值,请自行构建包含该标签的串

<test attr=”ddd”>

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


10.请使用socket相关函数(非curl)实现如下功能:构造一个post请求,发送到指定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时间戳)
设置超时为10秒,发出请求后,将http server的响应内容输出。
1.
Function encode($data, $sep = ‘&’){
2.
while (list($k,$v) = each($data)) {
3.
$encoded .= ($encoded ? "$sep" : "";
4.
$encoded .= rawurlencode($k)."=".rawurlencode($v);
5.
}
6.
Return $encoded;
7.
}
8.

9.
Function post($url, $post, $cookie){
10.
$url = parse_url($url);
11.
$post = encode($data, ‘&’);
12.
$cookie = encode($cookieArray, ‘;’);
13.
$fp = fsockopen($url['host'], $url['port'] ? $url['port'] : 80, $errno, $errstr, 10);
14.
if (!$fp) return "Failed to open socket to $url[host]";
15.

16.
fputs($fp, sprintf("OST %s%s%s HTTP/1.0\n", $url['path'], $url['query'] ? "?" : "", $url['query']));
17.
fputs($fp, "Host: $url[host]\n";
18.
fputs($fp, "Content-type: application/x-www-form-urlencoded\n";
19.
fputs($fp, "Content-length: " . strlen($encoded) . "\n";
20.
fputs($fp, "Cookie: $cookie\n\n";
21.
fputs($fp, "Connection: close\n\n";
22.
fputs($fp, "$post \n";
23.

24.
while (!feof($fp)) {
25.
echo fgets($fp, 12;
26.
}
27.
fclose($fp);
28.
}
29.

30.
$url = ‘http://www.example.com:8080/test’;
31.
$encoded = username=温柔一刀& pwd=
32.
$post = array(
33.
‘username’=> ‘温柔一刀’,
34.
‘pwd => ‘&123=321&321=123&’,
35.
‘intro => ‘Hello world!’
36.
);
37.
$cookie = array(
38.
‘cur_query’ => ‘you&me,
39.
‘last_tm’ => time() - 600,
40.
‘cur_tm ‘=> time()
41.
);
42.

43.
Post($url, $post, $cookie);
复制代码
11.你用什么方法检查PHP脚本的执行效率(通常是脚本执行时间)和数据库SQL的效率(通常是数据库Query时间),并定位和分析脚本执行和数据库查询的瓶颈所在?
1.脚本执行时间,启用xdebug,使用WinCacheGrind分析。
2.数据库查询,mysql使用EXPLAIN分析查询,启用slow query log记录慢查询。


PHP LAMP Engineer Test Paper
Question 1
What does <? echo count ("123" ?> print out?
A) 3
B) False
C) Null
D) 1
E) 0

Question 2
Which of the following snippets prints a representation of 42 with two decimal places?
A) printf("%.2d\n", 42);
B) printf("%1.2f\n", 42);
C) printf("%1.2u\n", 42);

Question 3
Given
$text = 'Content-Type: text/xml';
Which of the following prints 'text/xml'?
A) print substr($text, strchr($text, ':'));
B) print substr($text, strchr($text, ':') + 1);
C) print substr($text, strpos($text, ':') + 1);
D) print substr($text, strpos($text, ':') + 2);
E) print substr($text, 0, strchr($text, ':')
Question 4
What is the value of $a?
<?php
$a = in_array('01', array('1')) == var_dump('01' == 1);
?>
A) True
B) False
Question 5
What is the value of $result in the following PHP code?
<?php
function timesTwo($int) {
$int = $int * 2;
}
$int = 2;
$result = timesTwo($int);
?>;
Answer: NULL
Question 6
The code below ___________ because ____________.
<?php
class Foo {
?>
<?php
function bar() {
print "bar";
}
}
?>
A) will work, class definitions can be split up into multiple PHP blocks.
B) will not work, class definitions must be in a single PHP block.
C) will not work, class definitions must be in a single file but can be in multiple PHP blocks.
D) will work, class definitions can be split up into multiple files and multiple PHP blocks.
Question 7
When turned on, ____________ will _________ your script with different variables from HTML forms and cookies.
A) show_errors, enable
B) show_errors, show
C) register_globals, enhance
D) register_globals, inject
Question 8
What will be the output of the following PHP code:
<?php
echo count(strlen("http://php.net");
?>
Answer: 1
Question 9
What is the best all-purpose way of comparing two strings?
A) Using the strpos function
B) Using the == operator
C) Using strcasecmp()
D) Using strcmp()
Question 10
What is the difference between "print()" and "echo()"?
Answer: print is a function,echo is a language construct

Yahoo! PHP 笔试题.rar

1.15 KB, 下载次数: 436


作者: linzhoulxyz    时间: 2011-01-27 22:13

作者: lygxy    时间: 2011-01-28 02:27

作者: starzhestarzhe    时间: 2011-01-28 10:03
狗日的,出点实用的行不
作者: brynx    时间: 2011-01-28 10:25
学习
作者: wanghuan43    时间: 2011-01-28 14:55
看了TX的,我是肯定没戏了!
作者: hmchzb19    时间: 2011-01-31 21:09
看看
作者: abcddt    时间: 2011-02-01 09:35

作者: yzxlyd    时间: 2011-02-01 14:28
好东西呀
作者: lukui306    时间: 2011-02-10 08:51

作者: 2gua    时间: 2011-02-10 09:10
虽说是基础,但要有扎实的PHP基础才成。
作者: lemon_hg    时间: 2011-02-11 16:12
看看 ~
作者: nff    时间: 2011-02-11 19:17
好东西得顶呀
作者: jiang1013nan    时间: 2011-02-13 10:41
经典。学习嗯。
作者: witer666    时间: 2011-02-13 21:02
谢谢
作者: zhishufei    时间: 2011-02-14 09:56
还回复!
作者: lnn1123    时间: 2011-02-14 10:48
看看
作者: bxsun    时间: 2011-02-14 16:49
学习了。。
作者: yywoainisq    时间: 2011-02-14 17:53

作者: hellblog    时间: 2011-02-15 17:58
看了面试题唉。。。。。。。。还是不够格啊
作者: songshu07    时间: 2011-02-15 23:04
up
作者: TottyAndBaty    时间: 2011-02-16 10:46
很早之前看过
作者: tellron    时间: 2011-02-16 11:33
回复 1# lesson001
mark
作者: yuriyan    时间: 2011-02-16 16:21
{:3_183:}
作者: xiao7ng    时间: 2011-02-16 17:52
see see
作者: lib    时间: 2011-02-16 21:39
看看情况
作者: clcxxxx    时间: 2011-02-17 10:05

作者: 点滴永恒    时间: 2011-02-17 10:45
我目前在面试PHP工作,想看看
作者: sclzjl    时间: 2011-02-18 14:26

作者: chris lung    时间: 2011-02-18 16:37
好东西好东西
作者: wb521    时间: 2011-02-20 10:43
hao thank you ....
作者: xinglu1983    时间: 2011-02-21 09:25

作者: zhangyuan9zy    时间: 2011-02-21 10:12
谢谢楼主分享,我需要学习了。。。。
作者: venker    时间: 2011-02-21 10:25
感谢分享{:2_167:}{:2_167:}{:2_167:}
作者: weixiang096    时间: 2011-02-22 20:56
哈哈,找好久了
作者: suoxin117    时间: 2011-02-22 21:41
hjh
作者: dahai0510586    时间: 2011-02-23 09:06
回复 1# lesson001


    123123123123123123123123123123
作者: wutwei    时间: 2011-02-23 17:53
好好学习天天向上
作者: zr0128    时间: 2011-02-25 11:33
这题,够有意思的。
作者: hwangato    时间: 2011-02-27 08:55
回复 1# lesson001


    good
作者: seacoastboy    时间: 2011-02-27 09:16

作者: yc2266    时间: 2011-03-02 13:26
再来做一次
作者: askingyj    时间: 2011-03-02 21:06
呵呵 想看看
作者: tianxiaochun    时间: 2011-03-03 10:55
太感谢了,正需要呢
作者: xjm522    时间: 2011-03-08 11:01
下下来先看看
作者: zhang6464    时间: 2011-03-08 14:04
呵呵,收下,过几天要投腾讯呢
作者: 不能解决的巴哥    时间: 2011-03-10 11:05
Gan Fa Yin Cang Tie, TJJTDS...
{:3_183:}FireFox版隐藏贴回复机自动回复
作者: sickcat2004    时间: 2011-03-10 12:58
看看
作者: jhinux    时间: 2011-03-10 21:51
看看
作者: xp2059    时间: 2011-03-11 09:10
顶一个,要下载
作者: hgh_home    时间: 2011-03-11 09:34
路过,觉得还不错
作者: shupan001    时间: 2011-03-11 15:51
回复 1# lesson001


   
作者: miracle602    时间: 2011-04-01 17:01

作者: PKkingSon    时间: 2011-04-02 10:51
zhege 要看
作者: meilove812    时间: 2011-04-06 13:36
好东西。谢谢分享
作者: stabilization    时间: 2011-04-06 17:35
这个一定要看看
作者: cigerma    时间: 2011-04-06 20:29

作者: ccq1947    时间: 2011-04-07 14:41
回复 1# lesson001


    看看
作者: wodentt    时间: 2011-04-08 16:49
学习 谢谢分享
作者: songsy    时间: 2011-04-08 17:34
呵呵,有些题目是比较难!
作者: wangyaoysu    时间: 2011-04-08 18:33

作者: surfire91    时间: 2011-04-11 16:54
很久没做过题了,看看
作者: terryszy    时间: 2011-04-13 09:19

作者: terryszy    时间: 2011-04-13 09:20
冯巩hjkjkhjkjhk
作者: superdeng1986    时间: 2011-04-13 22:22
看看。。。。。。。。。。。。。
作者: moxuanyuan    时间: 2011-04-14 01:09

作者: jsakura    时间: 2011-04-14 19:10
做做笔试题玩..
作者: hosunion    时间: 2011-04-19 11:33
不错。学习了
作者: plzhuangyuan    时间: 2011-04-20 10:26
rhf rhf
作者: StartNow    时间: 2011-04-21 14:20
为啥一定要回帖才能看呢!
作者: caipj    时间: 2011-04-22 14:25

作者: ntds    时间: 2011-04-22 17:36
看看,谢谢了
作者: zjq8188    时间: 2011-04-23 00:20

作者: yangyang1581    时间: 2011-04-23 22:48
我路过看下`````
作者: brianzhuxd    时间: 2011-04-26 13:10

作者: kiqq2003    时间: 2011-04-26 13:10
看看新浪的
作者: sdsuper    时间: 2011-04-26 15:16
cc
作者: otchjh    时间: 2011-04-26 15:37
看看
作者: fancy1921    时间: 2011-04-29 10:33

作者: nbgod    时间: 2011-04-29 11:15
估计很变态的题目...
作者: qianshan520    时间: 2011-04-29 20:08
回复 1# lesson001


    cugi;
作者: wubai148    时间: 2011-05-01 22:33
有这样子的么
作者: huanghua581    时间: 2011-05-01 23:08
我来做做。。
作者: zhenqiao_2007    时间: 2011-05-02 03:09

作者: sharmy    时间: 2011-05-03 11:08
再收集多点吧
作者: udonmai    时间: 2011-05-04 19:02
回复 1# lesson001


    看看呀~
作者: xiaoao133    时间: 2011-05-04 20:58
upup,看附件
作者: FlySkype    时间: 2011-05-06 08:28
学习一下,看看难不难
作者: AmboLong    时间: 2011-05-06 13:46
lookup
作者: sunceenjoy    时间: 2011-05-06 14:39
have a look
作者: jeff_1987    时间: 2011-05-06 16:36

作者: vus520    时间: 2011-05-09 14:43

作者: scgywx    时间: 2011-05-09 17:18
好吧,回复吧。
作者: flyingnn    时间: 2011-05-09 18:58
看一下是什么.
作者: expert1    时间: 2011-05-10 09:53

作者: l277679541    时间: 2011-05-11 15:55
瞧下~
作者: cainiaogaofei    时间: 2011-05-11 16:05
chou  chou   xue  xi  xia
作者: zwfec    时间: 2011-05-11 16:16
这些天正在看这个呢
作者: myem007    时间: 2011-05-12 01:29
回复 1# lesson001


    看看原创的东西
作者: metlive    时间: 2011-05-12 15:19
看一看什么东西了。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2