免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 662862 | 回复: 456
打印 上一主题 下一主题

PHP工程师笔试题汇总 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-01-27 21:16 |只看该作者 |倒序浏览
腾讯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

论坛徽章:
0
2 [报告]
发表于 2011-01-27 22:13 |只看该作者

论坛徽章:
0
3 [报告]
发表于 2011-01-28 02:27 |只看该作者

论坛徽章:
0
4 [报告]
发表于 2011-01-28 10:03 |只看该作者
狗日的,出点实用的行不

论坛徽章:
0
5 [报告]
发表于 2011-01-28 10:25 |只看该作者
学习

论坛徽章:
0
6 [报告]
发表于 2011-01-28 14:55 |只看该作者
看了TX的,我是肯定没戏了!

论坛徽章:
13
CU大牛徽章
日期:2013-03-14 14:14:082016科比退役纪念章
日期:2016-07-22 11:15:35数据库技术版块每日发帖之星
日期:2016-05-27 06:20:002015亚冠之吉达阿赫利
日期:2015-08-05 10:06:542015年亚洲杯之韩国
日期:2015-04-01 16:05:42双鱼座
日期:2014-11-13 11:04:24丑牛
日期:2014-07-25 17:29:54子鼠
日期:2014-04-25 12:25:45丑牛
日期:2014-04-17 08:35:48巨蟹座
日期:2014-04-16 16:50:05CU大牛徽章
日期:2013-03-14 14:14:29CU大牛徽章
日期:2013-03-14 14:14:26
7 [报告]
发表于 2011-01-31 21:09 |只看该作者
看看

论坛徽章:
0
8 [报告]
发表于 2011-02-01 09:35 |只看该作者

论坛徽章:
0
9 [报告]
发表于 2011-02-01 14:28 |只看该作者
好东西呀

论坛徽章:
0
10 [报告]
发表于 2011-02-10 08:51 |只看该作者
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP