关于国内著名互联网企业PHP笔试试题

来源:范文网 1.12W

国内著名互联网企业pHp笔试题

关于国内著名互联网企业PHP笔试试题

面对目前全球金融危机,国内动荡的互联网环境,那冬天就要到来,大家也在积极的寻找一个过冬的窝,所以估计辞职跳槽的人很多,特别为大家分享一些各个著名公司的pHp笔试题,为大家求职就业打好坚实基础,希望大家都安然度过这个互联网的冬季!

【公司面试题之: pHp笔试题】 2008-10-7 上海公司pHp笔试题1. 禁用COOKIE 后 SEESION 还能用吗? 2. 抓取远程图片到本地,你会用什么函数?

3. 已知姓名A,姓名B,给一个求他们缘份的算法

4. 你觉得在pV10W的时候, 同等配置下,LUNIX 比WIN快多少?

5. 简述pOST 和GET传输的最大容量分别是多少?

6. 用最少的代码写一个求3值最大值的函数.

附部分答案(不保证是正确的解)

1. 能

2 fsockopen

3 随意

4 10倍?

5 1024B, 2MB

6 function($a,$b,$c){

return $a>$b? ($a>$c? $a : $c) : ($b>$c? $b : $c );

}

1. 禁用COOKIE 后 SEESION 还能用吗?

不能(java的servlet会在地址栏产生一个jsessionid,现在一些大集群,有些就是session复制搞的)

2. 抓取远程图片到本地,你会用什么函数?

socket & file

3. 已知姓名A,姓名B,给一个求他们缘份的算法

瞎扯谈,我压根就不相信!

4. 你觉得在pV10W的时候, 同等配置下,LUNIX 比WIN快多少?

不做优化的情况下一样

5. 简述pOST 和GET传输的最大容量分别是多少?

pOST, 中的文件中默认是2M,所以大于2M,GET没门, TCp中是C++的DWord,所以,小于1024B

6. 用最少的代码写一个求3值最大值的函数.

function max3($a,$b,$c){

return ($a>$b)?(($a>$c)? $a : $c): (($b>$c)? $b: $c);

}

【公司面试题之:腾讯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的指定端口的指定请求路径(如http://example: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的响应内容输出。复制内容到剪贴板代码: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.0n”, $url[path], $url[query] ? “?” : “”, $url[query]));

fputs($fp, “Host: $url[host]n”);

fputs($fp, “Content-type: application/x-www-form-urlencodedn”);

fputs($fp, “Content-length: ” . strlen($encoded) . “n”);

fputs($fp, “Cookie: $cookienn”);

fputs($fp, “Connection: closenn”);

fputs($fp, “$post n”);

while (!feof($fp)) {

echo fgets($fp, 128);

}

fclose($fp);

}

$url = ‘http://example: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脚本的.执行效率(通常是脚本执行时间)和数据库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(“%.2dn”, 42);

B) printf(“%1.2fn”, 42);

C) printf(“%1.2un”, 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

【公司面试题之:新浪pHp工程师笔试题】

1. 写一个函数,尽可能高效的,从一个标准 url 里取出文件的扩展名

例如: 需要取出 php 或

2. 在 HTML 语言中,页面头部的 meta 标记可以用来输出文件的编码格式,以下是一个标准的 meta 语句

请使用 pHp 语言写一个函数,把一个标准 HTML 页面中的类似 meta 标记中的 charset 部分值改为 big5

请注意:

(1) 需要处理完整的 html 页面,即不光此 meta 语句

(2) 忽略大小写

(3) ‘和” 在此处是可以互换的

(4) ‘Content-Type’ 两侧的引号是可以忽略的,但 ‘text/html; charset=gbk’ 两侧的不行

(5) 注意处理多余空格

3. 写一个函数,算出两个文件的相对路径

热门标签