php笔试题Word文档格式.docx

上传人:b****8 文档编号:22728124 上传时间:2023-02-05 格式:DOCX 页数:21 大小:29.27KB
下载 相关 举报
php笔试题Word文档格式.docx_第1页
第1页 / 共21页
php笔试题Word文档格式.docx_第2页
第2页 / 共21页
php笔试题Word文档格式.docx_第3页
第3页 / 共21页
php笔试题Word文档格式.docx_第4页
第4页 / 共21页
php笔试题Word文档格式.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

php笔试题Word文档格式.docx

《php笔试题Word文档格式.docx》由会员分享,可在线阅读,更多相关《php笔试题Word文档格式.docx(21页珍藏版)》请在冰豆网上搜索。

php笔试题Word文档格式.docx

有一个表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<

specialTime))

从性能上考虑上述的查询语句有什么不足?

如何进行优化?

Yahoo!

PHP 

笔试题】

1.Whichofthefollowingwillnotaddjohntotheusersarray?

1).$users[]='

john'

;

2).array_add($users,'

);

3).array_push($users,'

4).$users||='

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 

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 

andPerldistinguishbetweenarraysandhashes?

19.HowcanyougetroundthestatelessnatureofHTTPusing 

PHP?

20.WhatdoestheGDlibrarydo?

21.Nameafewwaystooutput(print)ablockofHTMLcodein 

22.Is 

betterthanPerl?

–Discuss.

这里有参考答案:

酷讯PHP工程师笔试题】

PHP&

HTML基础操作题

●有三个php文件位于同一目录下,内容为

a.php:

-------

php 

functionfa(){echo"

inFunctionA\n"

}?

>

b.php:

include'

a.php'

?

functionfb(){fa();

echo"

inFunctionB\n"

}?

c.php:

b.php'

fa();

fb();

使用浏览器访问c.php,请问是否存在问题。

如果存在问题,请指出修正方法并写出浏览器查看效果

如果不存在问题,请写出浏览器查看效果

●从表login中选出name字段包含admin的前10条结果所有信息的sql语句

●准确的指出以下代码的显示结果

tableborder=1width=500style="

text-align:

center;

tr>

<

tdrowspan=2width=50%height=50>

a<

/td>

tdwidth=50%eight=25>

d<

/tr>

tdwidth=50%height=25>

b<

trheight=25>

tdcolspan=2>

c<

/table>

style>

.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:

right:

#0000FF;

/style>

divclass="

a"

divid="

b"

/div>

c"

●请说明HTML文档中DTD的意义和作用

●判断以下代码是否正确,如果有错,请指出错误,如果正确,请指出运行结果

vararr=newArray(newArray(1,2,3,4),

newArray('

abc'

"

def"

xyz"

),

for(i=0;

i<

arr.length;

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属性值,请自行构建包含该标签的串 

testattr=”ddd”>

testattr\s*=\s*[“&

brvbar;

’](.*?

)[”&

’].*?

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['

]:

80,$errno,$errstr,10);

if(!

$fp)return"

Failedtoopensocketto$url[host]"

fputs($fp,sprintf("

POST%s%s%sHTTP/1.0\n"

$url['

path'

query'

]));

fputs($fp,"

Host:

$url[host]\n"

Content-type:

application/x-www-form-urlencoded\n"

Content-length:

.strlen($encoded)."

\n"

Cookie:

$cookie\n\n"

Connection:

close\n\n"

$post\n"

while(!

feof($fp)){ 

echofgets($fp,128);

fclose($fp);

$url=‘:

8080/test’;

$encoded=username=温柔一刀&

pwd= 

$post=array( 

‘username’=>

‘温柔一刀’, 

‘pwd=>

‘&

’, 

‘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记录慢查询。

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"

C)printf("

%1.2u\n"

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,'

D)printsubstr($text,strpos($text,'

)+2);

E)printsubstr($text,0,strchr($text,'

) 

Question4 

Whatisthevalueof$a?

$a=in_array('

01'

array('

1'

))==var_dump('

==1);

A)True 

Question5 

Whatisthevalueof$resultinthefollowing 

code?

functiontimesTwo($int){ 

$int=$int*2;

$int=2;

$result=timesTwo($int);

Answer:

NULL 

Question6 

Thecodebelow___________because____________. 

classFoo{ 

functionbar(){ 

print"

bar"

A)willwork,classdefinitionscanbesplitupintomultiple 

blocks. 

B)willnotwork,classdefinitionsmustbeinasingle 

block. 

C)willnotwork,classdefinitionsmustbeinasinglefilebutcanbeinmultiple 

D)willwork,classdefinitionscanbesplitupintomultiplefilesandmultiple 

Question7 

Whenturnedon,____________will_________yourscriptwithdifferentvari

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 职业教育 > 中职中专

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1