【公司面试题之: PHP笔试题】
1. 禁用COOKIE 后 SEESION 还能用吗?
2. 抓取远程图片到本地,你会用什么函数?
3. 已知姓名A,姓名B,给一个求他们缘份的算法
4. 你觉得在PV10W的时候, 同等配置下,LUNIX 比WIN快多少?
5. 简述POST 和GET传输的最大容量分别是多少?
6. 用最少的代码写一个求3值最大值的函数.
答:1、cookie是保存在本地的,而seesion是保存在服务器上的。所以两者没有直接的关系,禁用cookie后seesion依然可以用。
2、用file_get_contents函数,ex:
<?php
$img = file_get_contents(‘#39;);
file_put_contents(‘1.gif’,$img);
echo ‘<img src=”1.gif”>’;
?>
3、<?php
function is_gfriend($na,$nb)
{
$random1=rand(1,5);//计算他们有1/5的缘分
$random2=rand(1,5);
if ($random1==$random2)
return $na.”+”.$nb.”你们有缘分”;
else
return $na.”+”.$nb.”可惜无缘份”;
}
echo is_gfriend(a,b);
?>
4、
公司面试题之:百度Web开发工程师笔试题】
2007-11-07百度笔试题(web开发和新产品搜索方向)
第一部分:
1.解释下面语句的意思:document.form[“formName”].submit;
2.有下面语句:
<input id=”txt” type=”text” value=”baidu” />
编写代码,当鼠标划过文本框,自动选中文本框中的内容。
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.谈关于客户体验的问题。
答案:1、获取formName表单submit按钮元素。
2、 <input id=”txt” type=”text” value=”baidu” οnmοuseοver=”javacript:document.getElementById(‘txt’).select()” />
3、<?php
$a=”09″;
echo ( int ) $a;
echo “<br>”;
echo intval(“09”);
?>
4、<?php $num = “1234567890.11”;
$num = preg_replace(‘/(?<=[0-9])(?=(?:[0-9]{3})+(?![0-9]))/’, ‘,’, $num);
echo $num; ?>
6、$t= 1986;
switch ($t)
{
case 1986:
echo “牛”;
break;
case “”:
break;
case “”:
break;
……
}
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.CREATE TABLE topid{
topicId int not null primary key auto_increment,
title text,
author varchar(30),
content blob,
isDeleted int
…… //好像在author上定义了一个索引
}
CREATE TABLE reply{
topicId int foreign key,
replyId int primary key auto_increment,
replyAuthor varchar(30),
replyTime datetime,
context blob
……. //定义了一个索引和key
}
一个为主题表,一个为回复表。
1.问从性能上考虑,这样做有什么不足。
2.查询回复时间不超过一个特定的时间段,回复的作者名字以MIKE开头的主题
的title,以如下的查询:
select * from topic where replyid in (select replyid from reply where
replyAuthor like ‘mike%’ and (currentTime()-replyTime<specialTime))
从性能上考虑上述的查询语句有什么不足?
如何进行优化?
答案:1、数据库触发器和中断机制是数据库自动完成的,而ajax触发器是用户激发的。ajax把GUI和数据库异步优化。
2、<?php
$fp=fopen(“aa.txt”,’r’); //英文文档aa.txt
while(!feof($fp)){
$char=fgets($fp);
}
$e= explode(“,”,$char);
$write=fopen(“doc.txt”,’w’);//没有doc.txt则创建
foreach ($e as $w)
{
if($w==$e[count($e)-1])//最后一个单词没有逗号输入if($w==end($e))
$w=ucwords($w);//第一个字母转大写
else
$w=ucwords($w).”,”;
echo $w;
fwrite($write,$w);//写入doc.txt 文档中
}
fclose($write);
fclose($fp);
?>
I love it when folks get together and share thoughts.
Great site, keep it up!
Hypogonadism in men causes decreased libido and sexual function
Such alternative medications may be used to treat mild to moderate symptoms, but it is possible that symptomatic improvements may derive in part from a placebo effect