腾讯PHP笔试?
1. 请对POSIX风格和兼容Perl风格两种正则表达式的主要函数进行类比说明
ereg preg_match
ereg_replace preg_replace
2. 请说明在中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属性值,请自行构建包含该标签的串
10.请使用socket相关函数(非curl)实现如下功能:构造一个post请求,发送到指定http server的指定端口的指定请求路径请求中包含以下变量:
用户名(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的响应内容输出。复制内容到剪贴板代码:Function encode($data, $sep = ‘&’){
while (list($k,$v) = each($data)) {
$encoded .= ($encoded ? "$sep" : "");
$encoded .= rawurlencode($k)."="rlencode($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", $url[path], $url[query] ? "?" : "", $url[query]));
fputs($fp, "Host: $url[host]");
fputs($fp, "Content-type: application/x-www-form-urlencoded");
fputs($fp, "Content-length: " . strlen($encoded) . "");
fputs($fp, "Cookie: $cookie");
fputs($fp, "Connection: close");
fputs($fp, "$post");
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
$url = ‘’;
$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脚本的执行效率(通常是脚本执行时间)和数据库SQL的效率(通常是数据库Query时间),并定位和分析脚本执行和数据库查询的瓶颈所在?
1.脚本执行时间,启用xdebug,使用WinCacheGrind分析。
2.数据库查询,mysql使用EXPLAIN分析查询,启用slow query log记录慢查询。
PHP LAMP Engineer Test Paper
Question 1
What does 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", 42);
B) printf("%1.2f", 42);
C) printf("%1.2u", 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?
$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?
function timesTwo($int) {
$int = $int * 2;
}
$int = 2;
$result = timesTwo($int);
?>;
Answer: NULL
Question 6
The code below ___________ because ____________.
class Foo {
?>
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:
echo count(strlen(""));
?>
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
-
GRE笔试答题卡问题解答
GRE笔试答题卡问题解答:1、TOPICNumber________________(是题库的顺序,还是给出的顺序?如果是给出的顺序,那要是argue呢,topicnumber上是写个1,还是空着?)解答:TOPICNO。是题库的顺序,这个你可以放心,试卷上会在每个题目前面标上对应的number的;2、LASTNAME(firstfourl...
-
北语面试、笔试的过程
北语复试的笔试分三个部分,共一百分,两个小时。语言学概论和古代汉语各占25分,现代汉语占50分,大部分都是基础题,只要初试过了,做这种题毫不费力,还有几道就不容易了,比如今年现代汉语有一道题让分析一下“如果。。就。。。”和“既然。。。就”里面的“如果”和“既然...
-
考研复试面试经验:你们都忘了还有笔试吗?
一直以来,我们关于考研复试指导的文章大多数都在关注面试内容,觉得复试中面试比笔试重要的多,也难搞定的多,这话确实没错,但也并不意味着笔试就可以被完全忽略掉,复试中的笔试与初始还是有一定区别的,一般来说,导师会从以下几个方面出题。专业知识面试对专业知识的考察...
-
高校在读生MBA联考笔试经验谈
本人有幸通过了今年的MBA联考笔试,并被某名牌高校录取,当然有一定的运气在里边,但对我这样一个基础并不是很好的考生来讲,自己半年来所下的功夫还是我成功的主要原因。我的经验是,无论你基础好坏,都是一句话:精心准备,丝毫不要放松。笔试究竟难在哪儿?单纯从考试大纲或...