0

0

网传是腾讯公司PHP程序员面试题

php中文网

php中文网

发布时间:2016-07-25 08:59:28

|

971人浏览过

|

来源于php中文网

原创

  1. while (list($k,$v) = each($data)) {

  2. $encoded .= ($encoded ? "$sep" : "");
  3. $encoded .= rawurlencode($k)."=".rawurlencode($v);
  4. }
  5. return $encoded;
  6. }
  7. Function post($url, $post, $cookie){

  8. $url = parse_url($url);
  9. $post = encode($data, ‘&’);
  10. $cookie = encode($cookieArray, ‘;’);
  11. $fp = fsockopen($url['host'], $url['port'] ? $url['port'] : 80, $errno, $errstr, 10);
  12. if (!$fp) return "Failed to open socket to $url[host]";
  13. fputs($fp, sprintf("POST %s%s%s HTTP/1.0\n", $url['path'], $url['query'] ? "?" : "", $url['query']));

  14. fputs($fp, "Host: $url[host]\n");
  15. fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
  16. fputs($fp, "Content-length: " . strlen($encoded) . "\n");
  17. fputs($fp, "Cookie: $cookie\n\n");
  18. fputs($fp, "Connection: close\n\n");
  19. fputs($fp, "$post \n");
  20. while (!feof($fp)) {

  21. echo fgets($fp, 128);
  22. }
  23. fclose($fp);
  24. }
  25. $url = ‘http://bbs.it-home.org:8080/test’;

  26. $encoded = username=温柔一刀& pwd=
  27. $post = array(
  28. ‘username’=> ‘温柔一刀’,
  29. ‘pwd => ‘&123=321&321=123&’,
  30. ‘intro => ‘Hello world!’
  31. );
  32. $cookie = array(
  33. ‘cur_query’ => ‘you&me,
  34. ‘last_tm’ => time() - 600,
  35. ‘cur_tm ‘=> time()
  36. );

    立即学习PHP免费学习笔记(深入)”;

    图可丽批量抠图
    图可丽批量抠图

    用AI技术提高数据生产力,让美好事物更容易被发现

    下载
  37. 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?

  1. $a = in_array('01', array('1')) == var_dump('01' == 1);
  2. ?>
复制代码

A) True B) False

Question 5 What is the value of $result in the following PHP code?

  1. function timesTwo($int) {
  2. $int = $int * 2;
  3. }
  4. $int = 2;
  5. $result = timesTwo($int);
  6. ?>;
复制代码

Answer: NULL

Question 6 The code below ___________ because ____________.

  1. class Foo {
  2. ?>
  3. function bar() {
  4. print "bar";
  5. }
  6. }
  7. ?>
复制代码

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:

  1. echo count(strlen("http://php.net"));
  2. ?>
复制代码

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速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

相关专题

更多
Word 字间距调整方法汇总
Word 字间距调整方法汇总

本专题整合了Word字间距调整方法,阅读下面的文章了解更详细操作。

2

2025.12.24

任务管理器教程
任务管理器教程

本专题整合了任务管理器相关教程,阅读下面的文章了解更多详细操作。

2

2025.12.24

AppleID格式
AppleID格式

本专题整合了AppleID相关内容,阅读专题下面的文章了解更多详细教程。

0

2025.12.24

csgo视频观看入口合集
csgo视频观看入口合集

本专题整合了csgo观看入口合集,阅读下面的文章了知道更多入口地址。

29

2025.12.24

yandex外贸入口合集
yandex外贸入口合集

本专题汇总了yandex外贸入口地址,阅读下面的文章了解更多内容。

58

2025.12.24

添加脚注通用方法
添加脚注通用方法

本专题整合了添加脚注方法合集,阅读专题下面的文章了解更多内容。

1

2025.12.24

重启电脑教程汇总
重启电脑教程汇总

本专题整合了重启电脑操作教程,阅读下面的文章了解更多详细教程。

3

2025.12.24

纸张尺寸汇总
纸张尺寸汇总

本专题整合了纸张尺寸相关内容,阅读专题下面的文章了解更多内容。

5

2025.12.24

Java Spring Boot 微服务实战
Java Spring Boot 微服务实战

本专题深入讲解 Java Spring Boot 在微服务架构中的应用,内容涵盖服务注册与发现、REST API开发、配置中心、负载均衡、熔断与限流、日志与监控。通过实际项目案例(如电商订单系统),帮助开发者掌握 从单体应用迁移到高可用微服务系统的完整流程与实战能力。

1

2025.12.24

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
php面试题实战视频教程
php面试题实战视频教程

共12课时 | 4.2万人学习

一周时间让你轻松掌握Linux
一周时间让你轻松掌握Linux

共153课时 | 21.2万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号