php笔试题.docx
- 文档编号:9592099
- 上传时间:2023-02-05
- 格式:DOCX
- 页数:21
- 大小:29.27KB
php笔试题.docx
《php笔试题.docx》由会员分享,可在线阅读,更多相关《php笔试题.docx(21页珍藏版)》请在冰豆网上搜索。
php笔试题
2008-10-7上海51.COM公司PHP笔试题
1.禁用COOKIE后SEESION还能用吗?
2.抓取远程图片到本地,你会用什么函数?
3.已知姓名A,姓名B,给一个求他们缘份的算法
4.你觉得在PV10W的时候,同等配置下,LUNIX比WIN快多少?
5.简述POST和GET传输的最大容量分别是多少?
6.用最少的代码写一个求3值最大值的函数.
【公司面试题之:
XXWeb开发工程师笔试题】
2007-11-07XX笔试题(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.谈关于客户体验的问题。
第二部分:
1.Ajax,数据库触发器,GUI,中断机制的共同思想。
谈一谈该种思想(机制)。
2.把一篇英文文档中所有单词的首字母转为大写,文档存在doc.txt中。
可以在多种编程语言中选择(C\C++,JAVA,PHP...)写出你的思路,尽量优化你的程序。
3.关于树的数据结构.
4.数据库优化:
有一个表PRODUCT(ID,NAME,PRICE,COUNT);
在执行一下查询的时候速度总是很慢:
SELECT*FROMPRODUCTWHEREPRICE=100;
在price字段上加上一个非聚簇索引,查询速度还是很慢。
(1)分析查询慢的原因。
(2)如何进行优化。
5.CREATETABLEtopid{
topicIdintnotnullprimarykeyauto_increment,
titletext,
authorvarchar(30),
contentblob,
isDeletedint
...... //好像在author上定义了一个索引
}
CREATETABLEreply{
topicIdintforeignkey,
replyIdintprimarykeyauto_increment,
replyAuthorvarchar(30),
replyTimedatetime,
contextblob
.......//定义了一个索引和key
}
一个为主题表,一个为回复表。
1.问从性能上考虑,这样做有什么不足。
2.查询回复时间不超过一个特定的时间段,回复的作者名字以MIKE开头的主题
的title,以如下的查询:
select*fromtopicwherereplyidin(selectreplyidfromreplywhere
replyAuthorlike'mike%'and(currentTime()-replyTime 从性能上考虑上述的查询语句有什么不足? 如何进行优化? 【公司面试题之: Yahoo! PHP 笔试题】 1.Whichofthefollowingwillnotaddjohntotheusersarray? 1).$users[]='john'; 2).array_add($users,'john'); 3).array_push($users,'john'); 4).$users||='john'; 2.What'sthedifferencebetweensort(),asort()andksort? Underwhatcircumstanceswouldyouuseeachofthese? 3.Whatwouldthefollowingcodeprinttothebrowser? Why? $num=10; functionmultiply(){ $num=$num*10; } multiply(); echo$num; 4.Whatisthedifferencebetweenareferenceandaregularvariable? Howdoyoupassbyreference&whywouldyouwantto? 5.Whatfunctionscanyouusetoaddlibrarycodetothecurrentlyrunningscript? 6.Whatisthedifferencebetweenfoo()&@foo()? 7.Howdoyoudebuga PHP application? 8.Whatdoes===do? What'sanexampleofsomethingthatwillgivetruefor'==',butnot'==='? 9.Howwouldyoudeclareaclassnamed“myclass”withnomethodsorproperties? 10.Howwouldyoucreateanobject,whichisaninstanceof“myclass”? 11.Howdoyouaccessandsetpropertiesofaclassfromwithintheclass? 12.Whatisthedifferencebetweeninclude&include_once? include&require? 13.Whatfunctionwouldyouusetoredirectthebrowsertoanewpage? 1).redir() 2).header() 3).location() 4).redirect() 14.Whatfunctioncanyouusetoopenafileforreadingandwriting? 1).fget(); 2).file_open(); 3).fopen(); 4).open_file();15.What'sthedifferencebetweenmysql_fetch_row()andmysql_fetch_array()? 16.Whatdoesthefollowingcodedo? Explainwhat'sgoingonthere. $date='08/26/2003'; printereg_replace(“([0-9]+)/([0-9]+)/([0-9]+)”,2/1/3,$date); 17.Givenalineoftext$string,howwouldyouwritearegularexpressiontostripalltheHTMLtagsfromit? 18.What'sthedifferencebetweentheway PHP andPerldistinguishbetweenarraysandhashes? 19.HowcanyougetroundthestatelessnatureofHTTPusing PHP? 20.WhatdoestheGDlibrarydo? 21.Nameafewwaystooutput(print)ablockofHTMLcodein PHP? 22.Is PHP betterthanPerl? –Discuss. 这里有参考答案: 【公司面试题之: 酷讯PHP工程师笔试题】 PHP&HTML基础操作题 ●有三个php文件位于同一目录下,内容为 a.php: ------- php functionfa(){echo"inFunctionA\n";}? > b.php: ------- php include'a.php';? > php functionfb(){fa();echo"inFunctionB\n";}? > c.php: ------- php include'a.php';? > php include'b.php';? > php fa();fb();? > 使用浏览器访问c.php,请问是否存在问题。 如果存在问题,请指出修正方法并写出浏览器查看效果 如果不存在问题,请写出浏览器查看效果 ●从表login中选出name字段包含admin的前10条结果所有信息的sql语句 ●准确的指出以下代码的显示结果 center;">
●准确的指出以下代码的显示结果
.a{
position:
relative;
height:
200px;
width:
500px;
border:
solid1px#000;
background:
#FFF;
}
#b,#c{position:
absolute;width:
250px;height:
90px;}
#b{top:
30px;left:
50px;background:
#FF0000;z-index:
1;}
#c{bottom:
30px;right:
50px;background:
#0000FF;}
●请说明HTML文档中DTD的意义和作用
●判断以下代码是否正确,如果有错,请指出错误,如果正确,请指出运行结果
vararr=newArray(newArray(1,2,3,4),
newArray('abc',"def","xyz"),
);
for(i=0;i document.write(arr[0]) } ●如何使用javascript获取当前DOM元素(obj)的左上角在整个文档中的位置 ●可以使用哪些方法使用javascript向服务器发出请求且不离开当前页面,简单对比各自的特点(如果存在) ● 请写出php连mysql连接中,获取下一个自增长id值的方法,可以写多个。 ● 请问cgi和fastcgi有什么不同,你在什么情况下会选择哪个 ● Php中如何判断一个字符串是否是合法的日期模式: 2007-03-1313: 13: 13。 要求代码不超过5行。 ● Php中,如何获得一个数组的键值? ● zendoptimizer是什么 ● 如何用命令把mysql里的数据备份出来 Linux操作: ●vi编辑器中,选中、复制、粘贴、删除的命令各是什么 ●获取文件行数 ●输入文件的最后5行到另一个文件中 ●查找文件中包含hello的行 ● 查找当前目录下所有目录名为CVS的子目录的命令 ● 删除当前目录下所有目录名为CVS的子目录的命令 ● 如何让一个程序在后台运行并把输入定向到指定的文件 ● 如何把一个文件的内容添加到另一个文件的末尾 ● 如何实时的显示一个文件的输出 ● 定时执行一个程序的方法有什么 ● Vi编辑器中,如何替换指定的字符串 ● 当更新后,cvs中文件有冲突时。 如何判断哪些你编辑的内容和更新下来的内容 【公司面试题之: 腾讯PHP工程师笔试题】 1.请对POSIX风格和兼容Perl风格两种正则表达式的主要函数进行类比说明 eregpreg_match ereg_replacepreg_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请求,发送到指定httpserver的指定端口的指定请求路径(如: 8080/test)。 请求中包含以下变量: 用户名(username): 温柔一刀 密码(pwd): &123=321&321=123& 个人简介(intro): Helloworld! 且该httpserver需要以下cookie来进行简单的用户动作跟踪: cur_query: you&me last_tm: ...(上次请求的unix时间戳,定为当前请求时间前10分钟) cur_tm: ...(当前请求的unix时间戳) 设置超时为10秒,发出请求后,将httpserver的响应内容输出。 复制内容到剪贴板代码: Functionencode($data,$sep=‘&’){ while(list($k,$v)=each($data)){ $encoded.=($encoded? "$sep": ""); $encoded.=rawurlencode($k)."=".rawurlencode($v); } Return$encoded; } Functionpost($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"Failedtoopensocketto$url[host]"; fputs($fp,sprintf("POST%s%s%sHTTP/1.0\n",$url['path'],$url['query']? "? ": "",$url['query'])); fputs($fp,"Host: $url[host]\n"); fputs($fp,"Content-type: application/x-www-form-urlencoded\n"); fputs($fp,"Content-length: ".strlen($encoded)."\n"); fputs($fp,"Cookie: $cookie\n\n"); fputs($fp,"Connection: close\n\n"); fputs($fp,"$post\n"); while(! feof($fp)){ echofgets($fp,128); } fclose($fp); } $url=‘: 8080/test’; $encoded=username=温柔一刀&pwd= $post=array( ‘username’=>‘温柔一刀’, ‘pwd=>‘&123=321&321=123&’, ‘intro=>‘Helloworld! ’ ); $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分析查询,启用slowquerylog记录慢查询。 PHP LAMPEngineerTestPaper Question1 Whatdoes echocount("123")? >printout? A)3 B)False C)Null D)1 E)0 Question2 Whichofthefollowingsnippetsprintsarepresentationof42withtwodecimalplaces? A)printf("%.2d\n",42); B)printf("%1.2f\n",42); C)printf("%1.2u\n",42); Question3 Given $text='Content-Type: text/xml'; Whichofthefollowingprints'text/xml'? A)printsubstr($text,strchr($text,': ')); B)printsubstr($text,strchr($text,': ')+1); C)printsubstr($text,strpos($text,': ')+1); D)printsubstr($text,strpos($text,': ')+2); E)printsubstr($text,0,strchr($text,': ') Question4 Whatisthevalueof$a? php $a=in_array('01',array('1'))==var_dump('01'==1); ? > A)True B)False Question5 Whatisthevalueof$resultinthefollowing PHP code? php functiontimesTwo($int){ $int=$int*2; } $int=2; $result=timesTwo($int); ? >; Answer: NULL Question6 Thecodebelow___________because____________. php classFoo{ ? > php functionbar(){ print"bar"; } } ? > A)willwork,classdefinitionscanbesplitupintomultiple PHP blocks. B)willnotwork,classdefinitionsmustbeinasingle PHP block. C)willnotwork,classdefinitionsmustbeinasinglefilebutcanbeinmultiple PHP blocks. D)willwork,classdefinitionscanbesplitupintomultiplefilesandmultiple PHP blocks. Question7 Whenturnedon,____________will_________yourscriptwithdifferentvari
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- php 笔试