0% found this document useful (0 votes)
165 views31 pages

Test Exam 1

The document discusses various PHP concepts and questions. It includes: 1. Questions about DOM methods for adding nodes, output of code using array_map and explode, comparing objects, output of a code block using pass by reference, and splitting a string. 2. Additional questions cover printf formatting, HTTP headers, object serialization, stream locking, string functions, array pointers, markup security, query string parsing, PDO classes, socket requests, and function output. 3. The document concludes with questions on include file locations, array summation, command execution security, reference behavior changes, prepared statements, cloning, static methods, optional references, header sending, and merging/reversing arrays.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
165 views31 pages

Test Exam 1

The document discusses various PHP concepts and questions. It includes: 1. Questions about DOM methods for adding nodes, output of code using array_map and explode, comparing objects, output of a code block using pass by reference, and splitting a string. 2. Additional questions cover printf formatting, HTTP headers, object serialization, stream locking, string functions, array pointers, markup security, query string parsing, PDO classes, socket requests, and function output. 3. The document concludes with questions on include file locations, array summation, command execution security, reference behavior changes, prepared statements, cloning, static methods, optional references, header sending, and merging/reversing arrays.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

1. ThemethodusedtocreateanewnodetobeaddedintoanXMLdocumentusingDOMisthe ___________method 2. Whatistheoutputofthefollowingcodeblock?

<?php $a = "The quick brown fox jumped over the lazy dog."; $b = array_map("strtoupper", explode(" ", $a)); foreach($b as $value) { print "$value "; } ?>

THEQUICKBROWNFOXJUMPEDOVERTHELAZYDOG. APHPError Thequickbrownfoxjumpedoverthelazydog. ArrayArrayArrayArrayArrayArrayArrayArrayArray thequickbrownfoxjumpedoverthelazydog.

3. Whencheckingtoseeiftwovariablescontainthesameinstanceofanobject,whichofthefollowing comparisonsshouldbeused? Answer... if($obj1>equals($obj2)&&($obj1instanceof$obj2)) if($obj1>equals($obj2)) if($obj1===$obj2) if($obj1instanceof$obj2) if($obj1==$obj2)

4. Whatistheoutputofthefollowingcode?
<?php function x10(&$number) $number *= 10; $count = 5; x10($count); echo $count; ?>

Answer... Error:UnexpectedT_VARIABLE 10 Noticeregardingpassbyreference 50 5

5. Whichofthefollowingisthebestwaytosplitastringonthe"="pattern? Answer... Theyallareequallypropermethods str_split($string,strpos($string,"=")) preg_split("=",$string); explode("="$string); 6. Considerthefollowingscript:

<?php $oranges = 10; $apples = 5; $string = "I have %d apples and %d oranges"; ??????? ?>

Whatcouldbeplacedinplaceof??????tooutputthestring: I have 5 apples and 10 oranges Answers:(choose2) str_format($string,$apples,$oranges); print($string,$apples,$oranges); printf($string,$apples,$oranges); printsprintf($apples,$oranges); sprintf($string,$oranges,$apples);

7. OnecandetermineifitispossibletosendHTTPheadersfromwithinyourPHPscriptusingwhichof thefollowingfunctions? Answer... apache_headers_enabled() is_headers_enabled() is_headers_sent() headers_sent() headers_enabled()

8. Whenanobjectisserialized,whichmethodwillbecalled,automatically,providingyourobjectwithan opportunitytocloseanyresourcesorotherwisepreparetobeserialized? Answer... __destroy() __serialize() __destruct() __shutdown() __sleep()

9. Howcanonetakeadvantageofthetimewaitingforalockduringastreamaccess,todoothertasks usingthefollowinglockingcodeasthebase: $retval = flock($fr, LOCK_EX); Answer... Useflock_lazy()insteadofflock() UseLOCK_EX|LOCK_NBinsteadofLOCK_EX UseLOCK_UNinsteadofLOCK_EX Checkthevalueof$retvaltoseeifthelockwasobtained Checktoseeif$retval==LOCK_WAIT 10. Whichofthefollowingfunctionswilltrimleadingand/ortrailingwhitespacefromastring? Answers:(choose3) ltrim() rtrim() wtrim() trim() str_replace() 11. Whichofthefollowingfunctionsareusedwiththeinternalarraypointertoaccomplishanaction? Answers:(choose4) key forward prev current next

12. Whenusingafunctionsuchasstrip_tags,aremarkupbasedattacksstillpossible? Answer... No,HTMLdoesnotposeanysecurityrisks Yes,evena<p>HTMLtagisasecurityrisk Yes,attributesofallowedtagsareignored No,strip_tagswillpreventanymarkupbasedattack

13. Whatisthebestapproachforconvertingthisstring: $string = "a=10&b[]=20&c=30&d=40+50"; Intothisarray?


array(4) { ["a"]=> string(2) "10" ["b"]=> array(1) { [0]=> string(2) "20" } ["c"]=> string(2) "30" ["d"]=> string(5) "40 50" }

Answer... Writeaparsercompletelybyhand,it'stheonlywaytomakesureit's100%accurate Usetheparse_str()functiontotranslateittoanarray() PassthevariabletoanotherPHPscriptviaanHTTPGETrequestandreturnthearrayasa serializedvariable Justcallunserialize()totranslateittoanarray() Writeastringparserusingstrtok()andunserialize()toconvertittoanarray 14. ImplementingyourownPDOclassrequireswhichstepsfromthelistbelow? Answers:(choose3) ExtendingthePDOStatementClass SetthePDO::ATTR_STATEMENT_CLASSparameter CallthePDO::setStatementClass()method ExtendthePDOclass SetthePDO::ATTR_USE_CLASSparamater

15. Whatiswrongwiththefollowingcodesnippet?Assumedefaultconfigurationvaluesapply.
<?php $fp = fsockopen('www.php.net', 80); fwrite($fp, "GET / HTTP/1.0\r\nHost: www.php.net\r\n"); $data = fread($fp, 8192); ?>

Answer... Therequestisblockingandmaycausefread()tohang TheHTTPrequestismalformed Thisscriptshouldberewrittenusingfgets()insteadoffread() Therequestisnonblockingandfread()maymisstheresponse Youcannotusefwrite()withfsockopen()

16. Whatistheoutputofthefollowingcode?
<?php function functionSplit() { $pre = 1; ?> <?php echo $pre; } functionSplit(); ?>

Answer... Error;functiondeclarationscannotbesplitovermultiplePHPsegments. Nothing 1 2

17. GiventhefollowingXMLdocumentinaSimpleXMLobject:
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>XML Example</title> </head> <body> <p> Moved to &lt;<a href="http://example.org/">http://www.example.org/</a>.&gt; <br/>

</p> </body> </html>

SelecttheproperstatementbelowwhichwilldisplaytheHREFattributeoftheanchortag. Answer... $sxe>body>p[0]>a[1]['href'] $sxe>body>p>a>href $sxe>body>p>a['href'] $sxe['body']['p'][0]['a']['href'] $sxe>body>p[1]>a['href']

18. Foranarbitrarystring$mystring,whichofthefollowingcheckswillcorrectlydetermineifthe stringPHPexistswithinit? Answer... if(strpos($mystring,"PHP")!==false) if(!strpos($mystring,"PHP")) if(strpos($mystring,"PHP")===true) if(strloc($mystring,"PHP")==true) if(strloc($mystring,"PHP")===false)

19. WhereshouldindirectlyexecutedPHPscripts(i.e.includefiles)bestoredinthefilesystem? Answer... OutsideoftheDocumentRoot Inthedocumentroot Anywhereyouwant Inthedatabase

20. The______functionisusedtoaddupthevaluesofeveryentrywithinanarray 21. WhenexecutingsystemcommandsfromPHP,whatshouldonedotokeepapplicationssecure?

Answers:(choose3) Removeallquotecharactersfromvariablesusedinashellexecution AvoidusingshellcommandswhenPHPequivlentsareavailable Hardcodeallshellcommands Escapeallshellarguments Escapeallshellcommandsexecuted

22. Considerthefollowingscript:
<?php function func(&$arraykey) { return $arraykey; // function returns by value! } $array = array('a', 'b', 'c'); foreach (array_keys($array) as $key) { $y = &func($array[$key]); $z[] =& $y; } var_dump($z); ?>

ThiscodehaschangedbehaviorinPHP5.Identifytheoutputofthisscriptasitwouldhavebeenin PHP4,aswellasthenewbehaviorinPHP5. Answers:(choose2) array('a','a','b') array('a','b','c') array('c','b','a') array('c','c','c') array('b','b','b')

24. Considerthefollowingcodesnippet:
<?php $query = "INSERT INTO mytable (myinteger, mydouble, myblob, myvarchar) VALUES (?, ?, ?, ?)"; $statement = mysqli_prepare($link, $query); if(!$statement) { die(mysqli_error($link)); } /* The variables being bound to by MySQLi don't need to exist prior to binding */ mysqli_bind_param($statement, "idbs", $myinteger, $mydouble, $myblob, $myvarchar); /* ???????????? */ /* execute the query, using the variables as defined. */ if(!mysqli_execute($statement)) { die(mysqli_error($link)); } ?>

Assumingthissnippetisasmallerpartofacorrectlywrittenscript,whatactionsmustoccurinplaceof the?????intheabovecodesnippettoinsertarowwiththefollowingvalues:10,20.2,foo, string? Answer... Atransactionmustbebegunandthevariablesmustbeassigned Eachvaluemustbeassignedpriortocallingmysqli_bind_param(),andthusnothingshouldbe done Usemysqli_bind_value()toassigneachofthevalues Assign$myinteger,$mydouble,$myblob,$myvarcharthepropervalues

24. Howcanyoumodifythecopyofanobjectduringacloneoperation? Answer... Putthelogicintheobject'sconstructortoalterthevalues Implmentyourownfunctiontodoobjectcopying Implementtheobject's__clone()method Implement__get()and__set()methodswiththecorrectlogic Implementthe__copy()methodwiththecorrectlogic

25. Whatistheprimarydifferencebetweenamethoddeclaredasstaticandanormalmethod? Answer... Staticmethodscanonlybecalledusingthe::syntaxandneverfromaninstance Staticmethodsdonotprovideareferenceto$this Staticmethodscannotbecalledfromwithinclassinstances Staticmethodsdon'thaveaccesstotheselfkeyword Thereisnofunctionaldifferencebetweenastaticandnonstaticmethod

26. Whatistheoutputofthefollowingcode?

<?php function byReference(&$variable = 5) { echo ++$variable; } byReference(); ?>

Answer... Nooutputorerror.Variablescannotbeoptionalandpassedbyreference.

5 6

27. OnecanensurethatheaderscanalwaysbesentfromaPHPscriptbydoingwhat? Answer... EnableheaderbufferinginPHP5 Settheheader.forceINIdirectivetotrue EnableoutputbufferinginPHP5 Thereisnowaytoensurethatheaderscanalwaysbeset,theymustalwaysbechecked Noneoftheabove

28. Whatshouldgointhemissingline?????belowtoproducetheoutputshown?
<?php $array_one = array(1,2,3,4,5); $array_two = array('A', 'B', 'C', 'D', 'E'); ??????? print_r($array_three); ?>

Result:
Array ( [5] [4] [3] [2] [1] ) => => => => => A B C D E

Answer... $array_three=array_merge(array_reverse($array_one),$array_two); $array_three=array_combine($array_one,$array_two); $array_three=array_combine(array_reverse($array_one),$array_two); $array_three=array_merge($array_one,$array_two); $array_three=array_reverse($array_one)+$array_two;

29. WhyisitimportantfromasecurityperspectivetoneverdisplayPHPerrormessagesdirectlytotheend user,yetalwayslogthem?

Answers:(choose2) Errormessageswillcontainsensitivesessioninformation Errormessagescancontaincrosssitescriptingattacks SecurityrisksinvolvedinloggingarehandledbyPHP Errormessagesgivetheperceptionofinsecuritytotheuser Errormessagescancontaindatausefultoapotentialattacker

30. WhatarethethreeaccessmodifiersthatyoucanuseinPHPobjects? Answers:(choose3) protected public static private final

31. Whatistheoutputofthefollowingcode?
<?php class MyException extends Exception {} class AnotherException extends MyException {} class Foo { public function something() { throw new AnotherException(); } public function somethingElse() { throw new MyException(); } } $a = new Foo(); try { try { $a->something(); } catch(AnotherException $e) { $a->somethingElse(); } catch(MyException $e) { print "Caught Exception"; } } catch(Exception $e) { print "Didn't catch the Exception!"; } ?>

Answer... "CaughtException"followedby"Didn'tcatchtheException!" Afatalerrorforanuncaughtexception "Didn'tcatchtheException!"

"Didn'tcatchtheException!"followedbyafatalerror "CaughtException"

32. Considerthefollowingscript:
<?php $dom = new DOMDOcument(); $dom->load("myxmlfile.xml"); foreach($dom->documentElement->childNodes as $child) { if(($child->nodeType == XML_ELEMENT_NODE) && $child->nodeName == "item") { foreach($child->childNodes as $item) { if(($item->nodeType == XML_ELEMENT_NODE) && ($item->nodeName == "title")) { print "$item->firstChild->data\n"; } } } } ?>

AssumingthereferencedXMLdocumentexistsandmatchestheparsinglogic,whatshouldbe displayedwhenthisscriptisexecuted? Answer... Noneoftheabove TheXMLofeach'title'node TheXMLofeach'item'node "Title"foreverytitlenodeinthedocument Thecontentsofevery'title'nodewhichexistsunderan'item'node

33. Howdoesonecreateacookiewhichwillexistonlyuntilthebrowsersessionisterminated? Answer... Youcannotcreatecookiesthatexpirewhenthebrowsersessionisterminated Settingtheexpirationtimeforacookietoatimeinthedistantfuture Donotprovideacookieexpirationtime EnableCookieSecurity Setacookiewithoutadomain

34. RetrievingacookienamedmycookieisdoneusingwhichofthefollowingPHPconstructs? Answer... cookies::get('mycookie') $_SERVER['cookies']['mycookie'] $_COOKIE['mycookie']

get_cookie('mycookie') Noneoftheabove

35. WhatXMLtechnologyisusedwhenyoumixtwodifferentdocumenttypesinasingleXML document? Answer... Validators DTD Transformations Namespaces

36. Whencomparingtwostrings,whichofthefollowingisacceptable? Answers:(choose4) $a===$b; strcasecmp($a,$b); strcmp($a,$b); $a==$b; str_compare($a,$b);

37. WhichofthefollowingfunctionsallowyoutointrospectthecallstackduringexecutionofaPHP script? Answers:(choose2) get_backtrace() get_function_stack() debug_backtrace() debug_print_backtrace() print_backtrace()

38. Giventhefollowingarray: $array = array(1,1,2,3,4,4,5,6,6,6,6,3,2,2,2); Thefastestwaytodeterminethetotalnumberaparticularvalueappearsinthearrayistousewhich function?

Answer... array_total_values array_count_values Aforeachloop count aforloop

39. Whichofthefollowingoperationsmustoccurpriortoanyoutputbeingsenttotheclient(assume outputbufferingisdisabled). Answers:(choose3) ModifyingSessionData ProcessingGETorPOSTdata ManipulatingCookiedata StartingaSession SendingHTTPHeaders

40. Whatistheoutputofthefollowing?

<?php function byRef(&$apples) { $apples++; } $oranges = 5; $apples = 5; byRef($oranges); echo "I have $apples apples and $oranges oranges"; ?>

Answer... Ihave6applesand6oranges Ihave6applesand5oranges Ihave5applesand6oranges Ihave5applesand5oranges

41. Whatisthebestmeasureonecantaketopreventacrosssiterequestforgery? Answer... Disallowrequestsfromoutsidehosts Addasecrettokentoallformsubmissions Turnoffallow_url_fopeninphp.ini

Filteralloutput Filterallinput

42. Considerthefollowingcode:
<?php session_start(); if(!empty($_REQUEST['id']) && !empty($_REQUEST['quantity'])) { $id = scrub_id($_REQUEST['id']); $quantity = scrub_quantity($_REQUEST['quantity']) $_SESSION['cart'][] = array('id' => $id, 'quantity' => $quantity) } /* .... */ ?>

Whatpotentialsecurityholewouldthiscodesnippetproduce? Answer... CrossSiteScriptingAttack Thereisnosecurityholeinthiscode CodeInjection SQLInjection CrossSiteRequestForgery

43. InPHP5objectsarepassedbyreferencetoafunctionwhen(Selecttheanswerthatisthemostcorrect): Answer... Always;objectsarepassedbyreferenceinPHP5 Whenthecallingcodepreceedsthevariablenamewitha& Never;objectsareclonedwhenpassedtoafunction Whenthefunctionparamaterlistingpreceedsthevariablenamewitha& 44. UnliketheoldMySQLextension,thenewMySQLiextensionrequiresthatyouprovidewhatwhen performingaquerywhenusingtheproceduralinterface? Answer... Thequeryidentifier Thedatabasename Allfunctionparameters Thedatabasehandle Thestatementhandle

45. _______canbeusedtoaddadditionalfunctionalitytoastream,suchasimplementationofaspecific protocolontopofanormalPHPstreamimplementation. Answer... Buffered Buckets Wrappers Filters

46. Whichofthefollowingfunctionswillsortanarrayinascendingorderbyvalue,whilepreservingkey associations? Answer... asort() usort() krsort() ksort() sort()

47. Considerthefollowingcodesegment:

<?php $xmldata = <<< XML <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>XML Example</title> </head> <body> <p> Moved to &lt;<a href="http://example.org/">http://www.example.org/</a>.&gt; <br/> </p> </body> </html> XML; $xml = xml_parser_create("UTF-8"); /* ??????? */ xml_parse($xml, $xmldata); function xml_start_handler($xml, $tag, $attributes) { print "Tag: $tag<br/>\n"; } function xml_end_handler($xml, $tag) { } ?>

Whatshouldbeplacedinplaceof??????abovetohavetheabovescriptdisplaythenameofeachtag withintheXMLdocument? Answer... xml_set_callback("xml_start_handler"); xml_set_element_handler($xml,"xml_start_handler","xml_end_handler"); xml_node_set_handler("xml_start_handler","xml_end_handler"); xml_node_set_handler("xml_start_handler");

48. Whatistheoutputofthefollowing?
<?php $a = 010; $b = 0xA; $c = 2; print $a + $b + $c; ?>

Answer... 20 22 18 $aisaninvalidvalue 2

49. Whatwouldyoureplace???????with,below,tomakethestringHello, World!bedisplayed?


<?php function myfunction() { ??????? print $string; } myfunction("Hello, World!"); ?>

Answer... Thereisnowaytodothis $string=$argv[1]; $string=$_ARGV[0]; list($string)=func_get_args(); $string=get_function_args()

50. WhichofthefollowingfunctionsarepartofPHP'sinternalIteratorinterface? Answers:(choose5) rewind() valid() next() key() current() 51. WhenmigratingthefollowingcodefromPHP4toPHP5,whatshouldbechanged?
<?php class MyClass {

function MyClass($param) { /* Do something with $param */ $this->_doSomething($param); } // Private method to MyClass function _doSomething($param) { /* Do something with $param */ }

} class AnotherClass extends MyClass { var $param = "foo";

} ?>

function AnotherClass() { parent::MyClass($this->param); }

Answers:(choose2) Accessmodifiersshouldbeaddedtomethods TheConstructorsfortheobjectsshouldbothberenamedto__construct Theuseoftheparentkeywordhaschangedto'super' Constructorsmusthavethesameparameterlists

52. DuringanHTTPauthentication,howdoesonedeterminetheusernameandpasswordprovidedbythe browser? Answer... ParsetheHTTPheadersmanuallyusinghttp_get_headers() Usetheget_http_username()andget_http_password()functions Usethe$_SERVER['HTTP_USER']and$_SERVER['HTTP_PASSWORD']variables Usethe$_SERVER['PHP_AUTH_USER']and$_SERVER['PHP_AUTH_PW']variables

Parsethe$_SERVER['REQUEST_URI']variable

53. Afingerprintofastringcanbedeterminedusingwhichofthefollowing? Answer... md5() hash() fingerprint() Noneoftheabove

54. Whatistheoutputofthefollowingscript?
<?php class ClassOne { protected $a = 10; public function changeValue($b) { $this->a = $b; } } class ClassTwo extends ClassOne { protected $b = 10; public function changeValue($b) { $this->b = 10; parent::changeValue($this->a + $this->b); } public function displayValues() { print "a: {$this->a}, b: {$this->b}\n"; } } $obj = new ClassTwo(); $obj->changeValue(20); $obj->changeValue(10); $obj->displayValues(); ?>

Answer... a:30,b:30 a:30,b:20 a:30,b:10 a:20,b:20 a:10,b:10

55. Whichofthefollowingisincorrect? Answers:(choose4) functionc(MyClass$a=newMyClass()) functiond($a=null) functione(&$a=30) functiona(&$a=array(10,20,30))

functionb($a=(10+2))

56. ConsiderthefollowingPHPscript:
<?php function get_socket($host, $port) { $fr = fsockopen($host, $port); stream_set_blocking($fr, false); return $fr; } // Assume $host1, $host2, etc are defined properly $write_map[] = array('fr' => get_socket($host1, $port1), 'data' => str_pad("", 500000, "A")); $write_map[] = array('fr' => get_socket($host2, $port2), 'data' => str_pad("", 500000, "B")); $write_map[] = array('fr' => get_socket($host3, $port3), 'data' => str_pad("", 500000, "C")); do { $write_sockets = array(); foreach($write_map as $data) { $write_sockets[] = $data['fr']; } $num_returned = stream_select($r = null, $write_sockets, $e = null, 30); if($num_returned) { foreach($write_sockets as $fr) { foreach($write_map as $index => $data) { if($data['fr'] === $fr) { $len = fwrite($fr, $data['buf']); if($len) { $data['buf'] = substr($data['buf'], $len); if(empty($data['buf'])) { fclose($data['fr']); /* ????????? */ } } } } } } } while(count($write_map)); ?>

Whatshouldgointhe???????aboveforthisscripttofunctionproperly? 57. WhichtwointernalPHPinterfacesprovidefunctionalitywhichallowyoutotreatanobjectlikean array? Answers:(choose2) iteration arrayaccess objectarray iterator array

58. WhenworkingwithSimpleXMLinPHP5,thefourbasicrulesonhowtheXMLdocumentis accessedarewhichofthefollowing? Answers:(choose4) Elementnamespacesaredenotedbythe'namespace'attribute convertinganelementtoastringdenotestextdata Nonnumericindexesareelementattributes Numericindexesareelements Propertiesdenoteelementiterators

59. SQLInjectionscanbebestpreventedusingwhichofthefollowingdatabasetechnologies? Answers:(choose1) Alloftheabove PreparedStatements PersistentConnections UnbufferedQueries Queryescaping

60. WhichPCREregularexpressionwillmatchthestringPhP5-rocks? Answer... /^[hp15]*\.*/i /[hp15]*\.?/ /[hp][15]*\.*/ /[PhP]{3}[15]{2,3}\.*$/ /[az15\]*/

61. The____________functionisusedtomodifytheamountoftimePHPwillwaitforastreambefore timingoutduringreadingorwriting.

62. ConsiderthefollowingexampleXMLdocument:
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>XML Example</title> </head> <body> <p> Moved to <<a href="http://example.org/">http://www.example.org/</a>.> <br> </p> </body> </html>

Whatiswrongwiththisdocument,andhowcanitbecorrected? Answers:(choose2) Thedocumentiscompletelyvalid AllspecialXMLcharactersmustberepresentedasentitieswithinthecontentofanode Alltagsmustbeclosed Youcannotspecifyanamespaceforthe<html>attribute TheDOCTYPEdeclarationismalformed

63. Inasituationwhereyouwantoneandonlyoneinstanceofaparticularobject,the________design patternshouldbeused.

64. Whenattemptingtopreventacrosssitescriptingattack,whichofthefollowingismostimportant? Answer... NotwritingJavascriptontheflyusingPHP FilteringOutputusedinformdata FilteringOutputusedindatabasetransactions WritingcarefulJavascript Filteringallinput

65. InPHP4youcoulditerateovereverymemberpropertyofanobjectusingforeach(),inPHP5to accomplishthesametaskonanonpublicarrayyoucouldusethe___________interface.

66. Whatiswrongwiththefollowingcode?
<?php function duplicate($obj) { $newObj = $obj; return $newObj; } $a = new MyClass(); $a_copy = duplicate($a); $a->setValue(10); $a_copy->setValue(20); ?>

Answer... Youmustusereturn&$newObjinstead Thereisnothingwrongwiththiscode duplicate()mustacceptitsparameterbyreference Youmustusethecloneoperatortomakeacopyofanobject duplicate()mustreturnareference

67. Whichofthefollowinglistofpotentialdatasourcesshouldbeconsideredtrusted? Answers:(choose1) Noneoftheabove $_ENV $_GET $_COOKIE $_SERVER

68. WhatisthebestwaytoiterateandmodifyeveryelementofanarrayusingPHP5? Answer... Youcannotmodifyanarrayduringiteration for($i=0;$i<count($array);$i++){/*...*/} foreach($arrayas$key=>&$val){/*...*/} foreach($arrayas$key=>$val){/*...*/} while(list($key,$val)=each($array)){/*...*/

69. UnlikeadatabasesuchasMySQL,SQLitecolumnsarenotexplicitlytyped.Instead,SQLite catagorizesdataintowhichofthefollowingcatagories? Answers:(choose2) textual unicode numeric binary constant

70. WhichofthefollowingSQLstatementswillimproveSQLitewriteperformance? Answers:(choose2) PRAGMAlocking_mode="Row"; PRAGMAcount_changes=Off; PRAGMAdefault_synchronous=Off; PRAGMAdefault_synchronous=On; PRAGMAlocking_mode="Table";

You might also like