/    Sign up×
Community /Pin to ProfileBookmark

Some PHP Zend Certification Questions – Please answer

Hi all..

I am thinking to write ZCE soon, here are some mock questions I got, please try to answer these questions if you guyz have time.. Here we go..

1)What does the following PHP script accomplish?

<?php
$dom = new DomDocument();
$dom->load(‘test.xml’);
$body = $dom->documentElement->getElementsByTagName(‘body’)->item(0);
echo $body->getAttributeNode(‘background’)->value. “n”;
?>

Answer…
Displays the content of every <body> node
Displays the “background” attribute for the first node in the XML document named “body”
Displays the content of every node that has a “background” node
Displays the “background” attribute of every node named “body”

2) What conditional should replace the ?????? below?

function redirect()
{
//checking headers already sent or not
if( ?????? )
{
header(“Location : $url”);
}

}

3) Which of the following function is used to determine whether a given stream is blocking or not ?

a) stream_get_blocking
b) stream_get_meta_data
c) stream_is_blocking
d) stream_get_blocking_mode

4) When running PHP in a shared host environment , what is the major security concern when it comes to session data?

a) Sessions on shared hosts are easily hijacked by outside malicious users
b) All of the above
c) You cannot use a custom data store in shared hosts
d) Session data stored in the file systemcan be read by other scripts on the same shared host
e) Users outside the shared host can access any site which created a session for them

5) Cookie which remains until a browser session is terminated?

6) Where should indirectly executed PHP scripts (ie, include files) be stored in the file system?

a) Outside the Document Root
b) In database
c) In the Document Root

7) What does the function do when passed two integers?

function magic($p,$q)
{

return ($q == 0) ? $p : magic($q, $p % $q);

}

8) When attempting to prevent a cross-site scripting attack, which of the following is most important?

a) Not writing javascript on the fly using PHP
b) Filtered output used in form data
c) Filetered ouotput used in database transactions
d) Writing careful javascript
e) Filtering all input

9) Prepared statements have which of the following advantages over traditional SQL statements?
a) They uses less bandwidth
b) They prevent syntax error
c) They prevent SQL injection
d) They are faster when performing the same query multiple times
e) They allow you to use transactions

10) The ____ contant in a CLI script is an automatically provided file resource representing standard input of the terminal.

a) STDIN
b) __STDIN__
c) STDIO
d) PHP::STDIO
e) STD_IN

11) Which is the best way to ensure that a user defined function is always passed an object as its single parameter?

a) function myFunction(stdClass $a)
b) function myFunction($a = stdClass)
c) Use is_object() within the function
d) there is no way
e) function myFunction(Object $a)

12) The following PHP script is an example of what design pattern

<?php

interface HashAlgorithm {

public function hash($value);

}

class MyClass {

private $value;

public function __construct($value) {

$this->value = $value;

}

public function hash(HashAlgorithm $a) {

return $a->hash($this->value);
}

}

class MD5Hash implements HashAlgorithm {

public function hash($value) {

return md5($hash);

}

}

$obj = new MyClass(“John”);
$obj->hash(mew MD5Hash());

?>

a) Controller
b) Strategy
c) Abstract Factory
d) Factory
e) Command Chain

13) Which variable reference would go in the spots indicated by ?????? in the code segment below?

<?php

$msg = “The Quick Brown Fox Jumped Over The Lazy Dog”;

$state = true;

$retval = “”;

for($i=0; (isset(??????)); $i++ )
{

if($state)
{
$retval .= strtolower(?????);
}
else
{
$retval .= strtoupper(?????);
}

$state = !$state;

}

print $retval;

?>

a) $msg{$i}
b) ord($msg)
c) chr($msg)
d) substr($msg,$i,2)

14) Which of the following is not valid syntax for creating a new array key ?

a) $a[] = $value;
b) $a{} = $value;
c) $a{0} = $value;
d) $a[$b=0] = $value;

15) What is wriong with the following code?

<?php

function duplicate($obj)
{

$newObj = $obj;

return $newObj;

}

$a = new MyClass();

$_copy = duplicate($a);

$a->setValue(10);

$a_copy->setValue(20);

?>

16) Which two internal PHP interfaces provide functionality which allow you to treat an object like an array?

a) iteration
b) arrayaccess
c) objectarray
d) iterator
e) array

17) When embedding PHP into XMl documents, what must be ensure?

a) Disabling of the short_tags in PHP.ini file
b) XML document must be well formed
c) That you have XPath support enabled in PHP
d) None

18) PHP5 supports which of the following XML parsing methods?

a) SAX
b) FastDOM
c) DOM
d) XPath
e) XML to Object Mapping

19)What XML technology is used when you mix two different document types in a single XMl document?

a) Transformations
b) Validators
c) DTD
d) Namespaces

20) Consider the code attemopts to execute a PDO query

<?php

try {
$dbh->exec($sql);
}
catch(PDOException $e) {

//display warning message
$info = $e->errorInfo;

}

?>

What does the error info array $info contains (each vaule) ?

21) When implementing permission system for your website, what should always be done with regards to the session ?

a) sessions should be cleared of all data and repopulated
b) The session key should be re-generated
c) The session should be destroyed

Thanks,
Subeesh.K.K

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @subeeshkk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...