php面试题_腾讯.doc_第1页
php面试题_腾讯.doc_第2页
php面试题_腾讯.doc_第3页
php面试题_腾讯.doc_第4页
php面试题_腾讯.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

【公司面试题之:腾讯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属性值,请自行构建包含该标签的串 10请使用socket相关函数(非curl)实现如下功能:构造一个post请求,发送到指定http server的指定端口的指定请求路径(如: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).=.rawurlencode($v); Return $encoded; Function post($url, $post, $cookie) $url = parse_url($url); $post = encode($data, &); $cookie = encode($cookieArray, ;); $fp = fsockopen($urlhost, $urlport ? $urlport : 80, $errno, $errstr, 10); if (!$fp) return Failed to open socket to $urlhost; fputs($fp, sprintf(POST %s%s%s HTTP/1.0n, $urlpath, $urlquery ? ? : , $urlquery); fputs($fp, Host: $urlhostn); 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 = url:8080/test/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(%.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) True B) False Question 5 What is the value of $result in the following PHP code? ; Answer: NULL Question 6 The code below _ because _. 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: 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第一题是最花时间的(9)大概内容是监控ip攻击ip数据已用文本记录下来 已经按时间有序 记录数量小于10000000 时间从00:00:00到23:59:59ip范围为-55文本输入格式为第一行为总数据行数 以后各行为记录数据每行前面是ip后面是攻击时间 如333:22:2234 13:33:45 23:14:11设置一个阈值在x秒内连续访问y次的(9)ip被认作是攻击ip(1秒内可有多个数据包包括来自同一ip的(9)根据记录文本输出并不再重复输出攻击ip 要求编程实现第二题是算法题 对于连续输入的(9)自然数(随机非连续)如 551 512512351234 等 每输入一个数则输出其中位数中位数定义当n为偶数时 中位数为n/2 当n为奇数时为n/2+1不知道有无记错 大概就是这样

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论