php面试题及答案分享

WBOY
Release: 2016-07-25 08:53:45
Original
928 people have browsed it
  1. $img = file_get_contents('http://www.baidu.com/img/baidu_logo.gif');
  2. file_put_contents('1.gif',$img);
  3. echo 'php面试题及答案分享 ';
  4. ?>
复制代码

3、

  1. function is_gfriend($na,$nb)

  2. {
  3. $random1=rand(1,5);//计算他们有1/5的缘分
  4. $random2=rand(1,5);
  5. if ($random1==$random2)
  6. return $na."+".$nb."你们有缘分";
  7. else
  8. return $na."+".$nb."可惜无缘份";
  9. }

  10. echo is_gfriend(a,b);
  11. ?>
复制代码

4、

公司面试题之:百度web开发工程师笔试题】

第一部分: 1.解释下面语句的意思:document.form["formname"].submit;

2.有下面语句: 编写代码,当鼠标划过文本框,自动选中文本框中的内容。

3.将字符09转换成十进制数字。

4.将1234567890转换成1,234,567,890 每3位用逗号隔开的形式。

5.关于html和css的,忘记了。

6.在文本框中输入一个年份,判断其生肖,并输出在文本框旁边。 对html和javaservlet都要求写出。

7.ajax从服务器取数据 {id:123, name:"baidu", username:"mm",checked:true}; 分析name对应的值("baidu").(题目较长,不记得了)

8.谈关于客户体验的问题。(脚本学堂 bbs.it-home.org 编辑整理)

答案:1、获取formname表单submit按钮元素。

2、

复制代码

3、

  1. $a="09";
  2. echo ( int ) $a;
  3. echo "
    ";
  4. echo intval("09");
  5. ?>
复制代码

4、

  1. $num = preg_replace('/(?echo $num; ?>
复制代码

6、

  1. $t= 1986;
  2. switch ($t)
  3. {
  4. case 1986:
  5. echo "牛";
  6. break;
  7. case "":
  8. break;
  9. case "":
  10. break;
  11. ……
  12. }
复制代码

8、从满意度、忍受度、回馈度分析。

第二部分:

1.ajax,数据库触发器,gui,中断机制的共同思想。谈一谈该种思想(机制)。

2.把一篇英文文档中所有单词的首字母转为大写,文档存在doc.txt中。可以在多种编程语言中选择(c\c++,java,php...)写出你的思路,尽量优化你的程序。

3.关于树的数据结构.

4.数据库优化: 有一个表 product(id,name,price,count); 在执行一下查询的时候速度总是很慢: select * from product where price=100; 在price字段上加上一个非聚簇索引,查询速度还是很慢。 (1)分析查询慢的原因。 (2)如何进行优化。

5.

  1. create table topid{
  2. topicid int not null primary key auto_increment,
  3. title text,
  4. author varchar(30),
  5. content blob,
  6. isdeleted int
  7. ...... //好像在author上定义了一个索引
  8. }
  9. create table reply{
  10. topicid int foreign key,
  11. replyid int primary key auto_increment,
  12. replyauthor varchar(30),
  13. replytime datetime,
  14. context blob
  15. ....... //定义了一个索引和key
  16. }
复制代码

一个为主题表,一个为回复表。

1.问从性能上考虑,这样做有什么不足。 2.查询回复时间不超过一个特定的时间段,回复的作者名字以mike开头的主题 的title,以如下的查询: (程序员之家 bbs.it-home.org 编辑整理)

  1. select * from topic where replyid in (select replyid from reply where
  2. replyauthor like 'mike%' and (currenttime()-replytime
复制代码

从性能上考虑上述的查询语句有什么不足? 如何进行优化?

答案:1、数据库触发器和中断机制是数据库自动完成的,而ajax触发器是用户激发的。ajax把gui和数据库异步优化。

2、

  1. $fp=fopen("aa.txt",'r'); //英文文档aa.txt
  2. while(!feof($fp)){
  3. $char=fgets($fp);
  4. }
  5. $e= explode(",",$char);
  6. $write=fopen("doc.txt",'w');//没有doc.txt则创建
  7. foreach ($e as $w)
  8. {
  9. if($w==$e[count($e)-1])//最后一个单词没有逗号输入if($w==end($e))
  10. $w=ucwords($w);//第一个字母转大写
  11. else
  12. $w=ucwords($w).",";
  13. echo $w;
  14. fwrite($write,$w);//写入doc.txt 文档中
  15. }
  16. fclose($write);
  17. fclose($fp);
  18. ?>
复制代码


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!