Zend认证试题.docx

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

Zend认证试题.docx

《Zend认证试题.docx》由会员分享,可在线阅读,更多相关《Zend认证试题.docx(82页珍藏版)》请在冰豆网上搜索。

Zend认证试题.docx

Zend认证试题

Zend认证试题

第一章(PHPProgrammingBasics)

ZendChina官方:

最重要的是要您要掌握好基础知识。

这些知识是需要您一直去关注和学习的,因为它们是学习PHP语言的根基。

考试中您没有准备到的部分也可能是您日常程序开发中不会接触到的知识,但是本章中的问题还是需要得到您的重视,毕竟,如果您对最基本知识了解不够,对于您更深入的学习和开发也会带来诸多不便。

1、Choosetheselectionthatbestmatchesthefollowingstatements:

PHPisa_____scriptinglanguagebasedonthe____engine.Itisprimarilyusedtodevelopdynamic

_____content,althoughitcanbeusedtogenerate____documents(amongothers)aswell.

A.Dynamic,PHP,Database,HTML

B.Embedded,Zend,HTML,XML

C.Perl-based,PHP,Web,Static

D.Embedded,Zend,Docbook,MySQL

E.Zend-based,PHP,Image,HTML

2、WhichofthefollowingtagsisnotavalidwaytobeginandendaPHPcodeblock?

A.<%%>

B.

?

>

C.

=?

>

D.

!

>

E.

php?

>

3、WhichofthefollowingisnotvalidPHPcode?

A.$_10

B.${“MyVar”}

C.&$something

D.$10_somethings

E.$aVaR

4、Whatisdisplayedwhenthefollowingscriptisexecuted?

A.Thevalueis:

Dog

B.Thevalueis:

Cat

C.Thevalueis:

Human

D.Thevalueis:

10

E.Dog

5、Whatisthedifferencebetweenprint()andecho()?

A.print()canbeusedaspartofanexpression,whileecho()can’t

B.echo()canbeusedaspartofanexpression,whileprint()can’t

C.echo()canbeusedintheCLIversionofPHP,whileprint()can’t

D.print()canbeusedintheCLIversionofPHP,whileecho()can’t

E.There’snodifference:

bothfunctionsprintoutsometext!

6、Whatistheoutputofthefollowingscript?

A.128

B.42

C.242.0

D.256

E.342

7、Whichvaluesshouldbeassignedtothevariables$a,$band$cinorderforthefollowingscripttodisplaythestringHello,World!

?

A.False,True,False

B.True,True,False

C.False,True,True

D.False,False,True

E.True,True,True

8、Whatwillthefollowingscriptoutput?

A.Astringof50randomcharacters

B.Astringof49copiesofthesamecharacter,becausetherandomnumbergeneratorhasnotbeen

initialized

C.Astringof49randomcharacters

D.Nothing,because$arrayisnotanarray

E.Astringof49‘G’characters

9、Whichlanguageconstructcanbestrepresentthefollowingseriesofifconditionals?

A.Aswitchstatementwithoutadefaultcase

B.Arecursivefunctioncall

C.Awhilestatement

D.Itistheonlyrepresentationofthislogic

E.Aswitchstatementusingadefaultcase

10、Whatisthebestwaytoiteratethroughthe$myarrayarray,assumingyouwanttomodifythevalueofeachelementasyoudo?

A.Usingaforloop

B.Usingaforeachloop

C.Usingawhileloop

D.Usingado…whileloop

E.Thereisnowaytoaccomplishthisgoal

11、Considerthefollowingsegmentofcode:

Whatshouldgointhemarkedsegmenttoproducethefollowingarrayoutput?

A.foreach($resultas$key=>$val)

B.while($idx*=2)

C.for($idx=1;$idx

D.for($idx*=2;STOP_AT>=$idx;$idx=0)

E.while($idx

12、Choosetheappropriatefunctiondeclarationfortheuser-definedfunctionis_leap().Assume

that,ifnototherwisedefined,theis_leapfunctionusestheyear2000asadefaultvalue:

A.functionis_leap($year=2000)

B.is_leap($yeardefault2000)

C.functionis_leap($yeardefault2000)

D.functionis_leap($year)

E.functionis_leap(2000=$year)

13、Whatisthevaluedisplayedwhenthefollowingisexecuted?

Assumethatthecodewas

executedusingthefollowingURL:

testscript.php?

c=25

A.25

B.-5

C.10

D.5

E.0

14、Considerthefollowingscript:

Each?

intheabovescriptrepresentsanintegerindexagainstthe$sarray.Inorderto

displaytheHello,World!

stringwhenexecuted,whatmustthemissingintegerindexesbe?

A.GroupA:

4,3,0,4,9,9GroupB:

7,8

B.GroupA:

1,3,0,4,9,9GroupB:

7,6

C.GroupA:

1,3,2,3,0,4GroupB:

5,8

D.GroupA:

0,4,9,9,9,9GroupB:

7,8

E.GroupA:

4,3,0,4,9,9GroupB:

7,8

15、Run-timeinclusionofaPHPscriptisperformedusingthe________construct,whilecompile-time

inclusionofPHPscriptsisperformedusingthe_______construct.

A.include_once,include

B.require,include

C.require_once,include

D.include,require

E.Alloftheabovearecorrect

16、Underwhatcircumstanceisitimpossibletoassignadefaultvaluetoaparameterwhiledeclaringa

function?

A.WhentheparameterisBoolean

B.Whenthefunctionisbeingdeclaredasamemberofaclass

C.Whentheparameterisbeingdeclaredaspassedbyreference

D.Whenthefunctioncontainsonlyoneparameter

E.Never

17、The____operatorreturnsTrueifeitherofitsoperandscanbeevaluatedasTrue,butnotboth.

YourAnswer:

____________________________

18、Howdoestheidentityoperator===comparetwovalues?

A.Itconvertsthemtoacommoncompatibledatatypeandthencomparestheresultingvalues

B.ItreturnsTrueonlyiftheyarebothofthesametypeandvalue

C.Ifthetwovaluesarestrings,itperformsalexicalcomparison

D.ItbasesitscomparisonontheCstrcmpfunctionexclusively

E.Itconvertsbothvaluestostringsandcomparesthem

19、Whichofthefollowingexpressionsmultiplythevalueoftheintegervariable$aby4?

(Choose2)

A.$a*=pow(2,2);

B.$a>>=2;

C.$a<<=2;

D.$a+=$a+$a;

E.Noneoftheabove

20、Howcanascriptcometoacleantermination?

A.Whenexit()iscalled

B.Whentheexecutionreachestheendofthecurrentfile

C.WhenPHPcrashes

D.WhenApacheterminatesbecauseofasystemproblem

答案附在下面,方便大家参考。

 

答案详解

 

1.唯一有意义的答案是B。

PHP是一种基于Zend引擎的脚本语言,它通常被嵌入在HTML代码中。

它主要被用来开发HTML文档,但是也可以用它来开发其他类型的文档,比如XML。

2.PHP编程中,人们不太使用<%%>和

?

>两个标签,但它们确实是合法的PHP界定符。

!

>标签是非法的,因此正确的答案是D。

记住,根据php.ini文件中的配置不同,这当中的某些标签无法在特定的情况下使用。

3.PHP变量以一个美元符号为开头,后面跟上任意数量的数字、字母和下划线。

${“MyVar”}是一个合法的变量名,它使用的是较松散的命名约定。

&$something是对$something的引用。

然而,变量名不能以数字为开头,$10_somethings是非法的,因此答案是D。

4.注意,$myarray的键值并没有打上引号。

所以,正在访问的键不是myvalue字符串,而是常量myvalue的值。

最终访问的是$myarray[10],值是Dog,答案是A。

5.尽管print()和echo()在绝大多数情况下可以互换使用,但它们之间还是有一处不同。

print()是函数,有返回值;echo()实际上是一个语言结构,没有返回值,并且不能在表达式中使用。

因此,答案是A。

6.%运算符表示取模,它返回两个操作数相除的余数。

<<是左移运算符,相当于乘以2的N次方。

最后的答案乘以了一个浮点数,改变了它的数据类型。

但是,由于小数点后是零,因此输出的结果不包含小数部分。

答案是256(D)。

7.根据条件式的逻辑,要想得到Hello,World!

字符串,必须要在第一个if结构中满足else的条件。

因此$a必须为False,然后$b也必须为False。

最内层的条件语句的实现要求先前的两个变量($a和$b)是False,而$c必须是True(答案是D)。

8.正确答案是C。

从PHP4.2.0开始,除非已经给定了一个伪随机整数列,否则不再需要用srand()函数初始化随机数生成器。

此外,即使随机数生成器没有被事先播种,脚本仍然会生成49个伪随机字符。

尽管$array变量是字符串,但可以用访问数组的方式进行访问——使用数字索引访问某个位置上的字符。

最后,for循环将从1开始执行到50,也就是执行了49次。

9.用一系列的if…else语句来检查一个条件的代码块,最适合用switch语句来替代。

复制PHP内容到剪贴板PHP代码:

因为if语句中有一个捕捉所有其他条件的else,对应的,switch代码块需要一个default。

正确答案是E。

10.通常情况下,foreach语句是遍历数组的首选。

但是,由于foreach语句是在数组的副本上进行操作,而我们需要给数组中每个元素重新赋值,所以在这里foreach就不适用了。

尽管也可以用while循环和do…while循环,但由于数组是顺序索引的,最合适的语句还是for语句。

因此答案是A。

 

11.由于题目只允许填写一行代码,唯一合适的是for循环,因此答案只能是C或者D。

要选出能生成正确结果的for循环,我们必须先复习一下for循环的构成要素。

PHP中,for循环是这样声明的:

for(<初始化>;<继续执行,直到>;<重复执行>)

<初始化>在循环开始时执行一次,然后for循环开始执行大括号内的代码,直到<继续执行,直到>的值为False。

每完成一次循环,执行一次<重复执行>。

因此,正确的代码块应该是:

for($idx=1;$idx

答案是C。

12.5个选项中,只有两个是合法的PHP函数声明(A和D)。

在这两个选项中,只有一个设置了参数的默认值——答案是A。

13.本题考察PHP中变量作用域的相关知识。

你必须明确global关键字是如何将变量引入本地域的,以及$_GET、$_POST、$_COOKIE、$_REQUEST等超级全局变量的作用域。

本题中,最终的数学表达式是5+25-25-10,等于-5,答案是B。

14.函数能被以一个包含着函数名的变量后面加上括号(以及必要的参数)的形式动态调用。

对于GroupA来说,合适的索引组合是0,4,9,9,9,9,产生字符串myfunction。

另一方面,参数将使用${}结构的可变变量。

对GroupB来说,合适的索引应该是7和8,等于${‘a’}$和{‘b’}——即$a和$b。

因此答案是D。

15.在较新版本的PHP中,require(或requier_once())和include()(或include_once())只有一个区别——如果包含的文件不存在,前者将产生一个致命错误,同时终止脚本的执行;而后者只会产生一个警告。

因此答案E正确。

16.当参数被声明为通过引用传递时,你不能给它赋默认值,此时解释器期望获得一个能在函数内部进行修改的变量。

答案是C。

17.正确答案是逻辑异或(xor)运算符。

18.全等运算符比较两个操作数的数据类型和值,两者中有一个不同,都会返回False。

因此答案是B。

19.答案是A和C。

A选项中,pow函数计算2的平方,答案是4。

C选项中,左移运算符将$a的值左移两位,相当于乘以4。

20.答案是A。

一段脚本并不会在执行到文件末尾时终止,所以当前文件才能被其他脚本包含。

至于PHP和Apache崩溃,这两个说法就太恶搞了。

第二章(Object-orientedProgrammingwithPHP4)

ZendChina官方:

尽管PHP4不是一个成功的面向对象技术的典范,但是它适用于建立一个可行的面向对象的架构——你只需要了解一个有缺陷的对象模型的缺陷在哪,并围绕着它小心处理。

即使PHP5在PHP处理对象的方式上已经带来了许多的变化,从而你可能受到吸引而忽视了PHP4的能力。

事实是,这个面向对象的程序设计是非常受大多数程序员欢迎的,这些程序员在开始开发自己的应用软件时都是使用这个"老"版本的PHP。

这导致了有大量的OOP代码,甚至在你转向PHP5之前,你也可能会经常使用到这些代码。

考试的OOP部分不仅仅测试常用的面向对象开发,同时也测试PHP4实现OOP的独特方式。

1.Whatistheconstructusedtodefinetheblueprintofanobjectcalled?

YourAnswer:

____________________________

2.Attheendoftheexecutionofthefollowingscript,whichvalueswillbestoredinthe$a->my_valuearray?

(Choose3)

A.c

B.b

C.a

D.d

E.e

3.Howcanyouwriteaclasssothatsomeofitspropertiescannotbeaccessedfromoutsideitsmethods?

A.Bydeclaringtheclassasprivate

B.Bydeclaringthemethodsasprivate

C.Itcannotbedone

D.Bywritingapropertyoverloadingmethod

4.Whichobject-orientedpatternwouldyouusetoimplementaclassthatmustbeinstantiatedonlyoncefortheentirelifespanofascript?

A.Model-view-controller

B.Abstractfactory

C.Singleton

D.Proxy

E.State

5.Aclasscanbebuiltasanextensionofotherclassesusingaprocessknownasinheritance.InPHP,howmanyparentscanachildclassinheritfrom?

A.One

B.Two

C.Dependsonsystemresources

D.Three

E.Asmanyasneeded

6.WhatOOPconstructunavailableinPHP4doesthefollowingscriptapproximate?

A.Multipleinheritance

B.Interfaces

C.Abstractmethods

D.Privatemethods

E.Functionoverloading

7.Assumethataclasscalledtestclassisdefined.Whatmustthenameofitsconstructormethodbe?

A.__construct

B.initialize

C.testclass

D.__testclass

E.OnlyPHP5supportsconstructors

8.Howcanaclassoverridethedefaultserializationmechanismforitsobjects?

A.Byimplementingthe__shutdownand__startupmethods

B.Bycallingregister_shutdown_function()

C.Byimplementing__sleep()and__wakeup()

D.Thedefaultserializationmechanismcannotbeoverridden

E.Byaddingtheclasstotheoutputbufferingmechanismusingob_start()

9.InPHP4,whichobject-orientedconstructsfromthefollowinglistarenotavailable?

•Abstractclasses

•Finalclasses

•Public,private,protected(PPP)methods

•Interfaces

A.Abstract

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

当前位置:首页 > 小学教育 > 数学

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

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