Special Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: netdisc

Zend 200-500 Zend PHP 5 Certification Exam Practice Test

Demo: 32 questions
Total 219 questions

Zend PHP 5 Certification Questions and Answers

Question 1

Webservices are primarily meant to support

Options:

A.

business-to-business communication

B.

machine-to-machine interaction

C.

improved accessibility for websites

Question 2

Would the following code catch a parse error?

try {

echo $label

} catch (Exception $e) {

echo $e->getMessage();

}

Options:

A.

Yes

B.

No

Question 3

Which piece of code will return the ASCII value of a character?

Options:

A.

(int)'t';

B.

ord('t');

C.

to_ascii('t');

D.

chr('t');

Question 4

Which of the following statements is correct?

Options:

A.

Interfaces can extend only one interface

B.

Interfaces can extend more than one interface

C.

Interfaces can inherit a method from different interfaces

D.

Interfaces can redeclare inherited methods

Question 5

What function should be used to escape command line arguments that are passed to commands executed from PHP?

Options:

A.

addslashes()

B.

quotemeta()

C.

escapeshellarg()

D.

escapeshellcmd()

E.

passthru()

Question 6

You analyze the code of a collegue and see, it uses the function strcasecmp. You try it out to see what it does and use the following function call:

strcasecmp('hello my dear!', 'Hello my DEAR!');

The function call returns "0". What does that mean?

Options:

A.

String 1 is less than string 2.

B.

The strings are considered equal.

C.

String 2 is less than string 1.

D.

The strings have equal length.

Question 7

What is the output of the following code?

class test {

public $value = 0;

function test() {

$this->value = 1;

} function __construct() {

$this->value = 2;

}}

$object = new test();

echo $object->value;

Options:

A.

2

B.

1

C.

0

D.

3

E.

No Output, PHP will generate an error message.

Question 8

Which of the listed changes would you make to the following PHP 4 code in order to make it most compliant with PHP 5? (Choose 2)

class Car {

var $model;

function Car($model) {

$this->model = $model;

} function toString() {

return "I drive a $this->model.";

}}

$c = new Car('Dodge');

echo $c->toString();

?>

Options:

A.

Change var to public or private

B.

Change function Car to function_construct

C.

Change "I drive a $this->model." to "I drive a {$this->model}."

D.

Change function toString()to static function toString()

Question 9

When PHP is running on a command line, what super-global will contain the command line arguments specified?

Options:

A.

$_SERVER

B.

$_ENV

C.

$GLOBALS

D.

$_POST

E.

$_ARGV

Question 10

Which of the following is NOT a valid function declaration?

Options:

A.

function x ($x1 = array())

B.

function x (A $x1)

C.

function x (A $x1 = null)

D.

function x ($x1 = $x2)

Question 11

After performing the following operations:

$a = array('a', 'b', 'c');

$a = array_keys(array_flip($a));

What will be the value of $a?

Options:

A.

array('c', 'b', 'a')

B.

array(2, 1, 0)

C.

array('a', 'b', 'c')

D.

None of the above

Question 12

What function allows resizing of PHP's file write buffer?

Options:

A.

ob_start()

B.

set_write_buffer()

C.

stream_set_write_buffer()

D.

Change the output_buffering INI setting via ini_set() function

Question 13

What will be the result of the following operation?

array_combine(array("A","B","C"), array(1,2,3));

Options:

A.

array("A","B",C",1,2,3)

B.

array(1,2,3,"A","B",C")

C.

array("A"=>1,"B"=>2,"C"=>3)

D.

array(1=>"A",2=>"B",3=>"C")

E.

array(1,2,3)

Question 14

Can a private static member be accessed from a public static method of the same class?

Options:

A.

Yes

B.

No

C.

Only if the class is defined as an abstract

Question 15

Which is the most secure approach for handling dynamic data in SQL queries?

Options:

A.

Use addslashes().

B.

Enable magic_quotes_gpc.

C.

Use prepared statements if supported by the database library, data-specific escaping functions otherwise.

D.

Use stored procedures.

Question 16

Which of the following functions are used to escape data within the context of HTML?

(Choose 2)

Options:

A.

htmlentities()

B.

addslashes()

C.

stripslashes()

D.

strip_tags()

E.

htmlspecialchars()

Question 17

You want to test if a string matches a relatively complex pattern. Which of the following functions can you use? (Choose 2)

Options:

A.

match()

B.

preg_match()

C.

ereg()

D.

regex()

Question 18

How can precisely one byte be read from a file, pointed by $fp? (Choose 2)

Options:

A.

fread($fp, 1);

B.

fgets($fp, 1);

C.

fgetss($fp, 1);

D.

fgetc($fp);

E.

All of the above

Question 19

What is the output of the following code?

$a = 3;

switch ($a) {

case 1: echo 'one'; break;

case 2: echo 'two'; break;

default: echo 'four'; break;

case 3: echo 'three'; break;

}

Options:

A.

one

B.

two

C.

three

D.

four

Question 20

What is the output of the following code?

1

2 $a = 'a'; $b = 'b';

3 echo isset($c) ? $a.$b.$c : ($c = 'c').'d';

4 ?>

Options:

A.

abc

B.

cd

C.

0d

Question 21

What is the output of the following code: echo "1" + 2 * "0x02";

Options:

A.

1

B.

3

C.

5

D.

20

E.

7

Question 22

What is the output of the following script?

1

2 function fibonacci ($x1, $x2)

3 {

4 return $x1 + $x2;

5 }

6

7 $x1 = 0;

8 $x2 = 1;

9

10 for ($i = 0; $i < 10; $i++) {

11 echo fibonacci($x1, $x2) . ',';

12 }

13 ?>

Options:

A.

1,2,3,4,5,6,7,8,9

B.

1,2,3,4,5,6,7,8,9,10,

C.

1,2,3,5,8,13,21,34,55,89,

D.

1,1,1,1,1,1,1,1,1,1,

Question 23

What will be the value of $b after running the following code?

$a = array('c', 'b', 'a');

$b = (array)$a;

Options:

A.

TRUE

B.

array('c', 'b', 'a')

C.

array(array('c', 'b', 'a'))

D.

None of the above

Question 24

When you need to process the values of columns in a database, you should:

Options:

A.

Only use built-in database functions

B.

Always use read the values as-is from the database and then process them with PHP

C.

Use built-in database functions for simple processing, and perform more complicated logic in PHP

D.

Use built-in database functions for complicated logic, and perform simpler functions in PHP

Question 25

What is the result of the following code?

$a = 1;

$b = "1";

var_dump($a === $b);

Options:

A.

bool(true

B.

bool(false)

C.

Parser error

D.

NULL

Question 26

Identify the security vulnerability in the following example:

1

2 mail('feedback@example.org',

3 'Feddback',

4 'Here is my feedback.',

5 "From: {$_COOKIE['email']}");

6 ?>

Options:

A.

Remote Code Injection

B.

Cross-Site Request Forgeries

C.

Email Injection

D.

None of the above

Question 27

What will the $array array contain at the end of this script?

1

2 function modifyArray (&$array)

3 {

4 foreach ($array as &$value)

5 {

6 $value = $value + 1;

7 }

8

9 $value = $value + 2;

10 }

11

12 $array = array (1, 2, 3);

13 modifyArray($array);

14 ?>

Options:

A.

2, 3, 4

B.

2, 3, 6

C.

4, 5, 6

D.

1, 2, 3

Question 28

What SimpleXML function is used to parse a file?

Options:

A.

simplexml_load_file()

B.

simplexml_load_string()

C.

load()

D.

loadFile()

E.

loadXML()

F.

None of the above.

Question 29

What type of class definition can be used to define multiple inheritance?

Options:

A.

Class

B.

Abstract

C.

Interface

D.

Final

Question 30

What is the file locking mode that should be used when writing to a file?

Options:

A.

LOCK_UN

B.

LOCK_SH

C.

LOCK_EX

D.

LOCK_NB

Question 31

What is the length of a string returned by: md5(rand(), TRUE);

Options:

A.

Depends on the value returned by rand() function

B.

32

C.

24

D.

16

E.

64

Question 32

You have a variable $test that contains sub-strings divided by a dash ("-"). How can you put every sub-string into an array element easily?

Options:

A.

extract($test, "-");

B.

explode("-", $test);

C.

to_array($test, "-");

D.

explode($test, "-");

Demo: 32 questions
Total 219 questions