New Year Special Limited Time Flat 70% Discount offer - Ends in 0d 00h 00m 00s - Coupon code: 70spcl

Zend 200-500 Zend PHP 5 Certification Exam Practice Test

Page: 1 / 22
Total 219 questions

Zend PHP 5 Certification Questions and Answers

Question 1

A script residing at <a href="http://example.com/phpcert/cookies.php">http://example.com/phpcert/cookies.php</a> contains the following code:

1 <?php

2 setcookie('name1', 'value1', time() + 60*60*24, '/');

3 setcookie('name1', 'value2');

4 ?>

The web browser is configured to accept all cookies. How many cookies will be set by this script?

Options:

A.

0

B.

1

C.

2

D.

3

Question 2

Given the following code, what will be the value of $a?

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

array_push($a, array(1, 2));

Options:

A.

array('a', 'b', 1, 2)

B.

array(1, 2, 'a', 'b')

C.

array(array(1, 2), 'a', 'b')

D.

None of the above

Question 3

How many elements does the $matches array contain after the following function call is performed?

preg_match('/^(\d{1,2}([a-z]+))(?:\s*)\S+ (?=200[0-9])/', '21st March

2006', $matches);

Options:

A.

1

B.

2

C.

3

D.

4

Question 4

Which of the following statements is NOT true?

a) Class constants are public

b) Class constants are being inherited

c) Class constants can omit initialization (default to NULL)

d) Class constants can be initialized by consts

Options:

A.

a)

B.

b)

C.

c)

D.

d)

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

Identify the security vulnerability in the following example:

1 <?php

2 echo "Welcome, {$_POST['name']}.";

3 ?>

Options:

A.

SQL Injection

B.

Cross-Site Scripting

C.

Remote Code Injection

D.

None of the above

Question 7

You want to run the following PHP 4 code with PHP 5. In the following example, which access modifier in PHP 5 is equivalent to "var"?

class Test {

var $tester;

}

Options:

A.

protected

B.

invisible

C.

public

D.

private

E.

outofscope

Question 8

Which methods can be used to overload object properties? (Choose 2)

Options:

A.

set(), get()

B.

__set(), __get()

C.

__put(), __receive(), __exists()

D.

set(), get(), isset()

E.

__isset(), __unset()

Question 9

What does the __FILE__ constant contain?

Options:

A.

The filename of the current script.

B.

The full path to the current script.

C.

The URL of the request made.

D.

The path to the main script.

Question 10

You want to present the following formatted number: "999.000.000,00". Which function call is correct?

Options:

A.

print format_number(999000000);

B.

print number_format(999000000);

C.

print number_format(999000000, 2, ',', '.');

D.

print number_format(999000000, 2);

E.

print_number(999000000, 2, ',', '.')

Question 11

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 12

Transactions are used to:

Options:

A.

guarantee high performance

B.

secure data consistency

C.

secure access to the database

D.

reduce the database server overhead

E.

reduce code size in PHP

Question 13

What is the purpose of the 4th argument to the file_get_contents() function?

Options:

A.

Indicate the number of bytes to read

B.

Specifies the stream context

C.

Indicates whether or not include_path should be used

D.

Identifies the starting offset

E.

None of the above

Question 14

How can you determine if magic_quotes_gpc is enabled? (Choose 2)

Options:

A.

Use the get_magic_quotes() function.

B.

Using the get_magic_quotes_runtime() function.

C.

Use the get_magic_quotes_gpc() function.

D.

Using ini_get('magic_quotes_gpc').

E.

Using ini_get('magic_quotes').

Question 15

What is the output of the following code?

printf('%4$d %2$s sit on 2 trees and eat %3$3.2f %1$s', "bananas",

"monkeys", 9, 99);

Options:

A.

%4$d %2$s sit on 2 trees and eat %3$3.2f %1$s

B.

99 monkeys sit on 2 trees and eat 9.00 bananas

C.

Monkeys Bananas sit on 2 trees and eat 9 99

D.

9 monkeys sit on 2 trees and eat 99 bananas

Question 16

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 17

What is the output of the following code?

1 <?php

2 function append($str)

3 {

4 $str = $str.'append';

5 }

6

7 function prepend(&$str)

8 {

9 $str = 'prepend'.$str;

10 }

11

12 $string = 'zce';

13 append(prepend($string));

14 echo $string;

15 ?>

Options:

A.

zceappend

B.

prependzceappend

C.

prependzce

D.

zce

Question 18

Which of the following XML declarations is NOT valid?

Options:

A.

B.

C.

D.

Question 19

What will the following code piece print?

echo strtr('Apples and bananas', 'ae', 'ea')

Options:

A.

Applas end benenes

B.

Epplas end benenes

C.

Apples and bananas

D.

Applas end bananas

Question 20

What will the following code print?

echo addslashes('I am a small "HTML" string, which is

\'invalid\'.');

Options:

A.

I am a small "HTML" string, which is 'invalid'.

B.

I am a small \"HTML\" string, which is \'invalid\'.

C.

I am a small \"HTML\" string, which is \\'invalid\\'.

D.

I am a small \"HTML\" string, which is \\\'invalid\\\'.

E.

I am a \small\<\/b\> "HTML" string, which is 'invalid'\<\/u\>.

Question 21

What will be the output value of the following code?

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

while (list(,$v) = each($array));

var_dump(current($array));

Options:

A.

bool(false)

B.

int(3)

C.

int(1)

D.

NULL

E.

Array

Question 22

What is the output of the following code?

$a = 1;

++$a;

$a*=$a;

echo $a--;

Options:

A.

4

B.

3

C.

5

D.

0

E.

1

Question 23

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 24

Which of the following superglobals does not contain data from the client?

Options:

A.

$_POST

B.

$_SESSION

C.

$_GET

D.

$_SERVER

Question 25

What is the output of the following code?

try {

class MyException extends Exception {};

try {

throw new MyException;

}

catch (Exception $e) {

echo "1:";

throw $e;

}c

atch (MyException $e) {

echo "2:";

throw $e;

}}

catch (Exception $e) {

echo get_class($e);

}

Options:

A.

A parser error, try cannot be followd by multiple catch

B.

1:

C.

2:

D.

1:Exception

E.

1:MyException

F.

2:MyException

G.

MyException

Question 26

What can prevent PHP from being able to open a file on the hard drive (Choose 3)?

Options:

A.

File system permissions

B.

File is outside of open_basedir

C.

File is owned by another user and safe_mode is enabled.

D.

File is inside the /tmp directory.

E.

PHP is running as the web server user.

Question 27

How can the constant defined below be accessed from within PHP?

class myClass {

const FOO = 'BAR';

}

Options:

A.

myClass::$FOO

B.

myClass::$$FOO

C.

myClass::FOO

D.

myClass::foo

E.

$foo::myClass

Question 28

How can XML parsing errors be suppressed in the SimpleXML extension?

Options:

A.

error_reporting(E_ALL^E_NOTICE);

B.

simplexml_disable_errors(TRUE);

C.

simplexml_ignore_errors(TRUE);

D.

libxml_use_internal_errors(TRUE);

E.

simplexml_load_file("file.xml", LIBXML_NOERROR);

Question 29

Which of the following statements about database connections are commonly true? (Choose 2)

Options:

A.

Database connections are closed after each SQL statement is executed

B.

Database connections are closed at the end of each request

C.

Database connections are only closed when the Web server shuts down

D.

A single database connection may serve more than one PHP application at the same time

Question 30

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

1 <?php

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 31

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

Options:

A.

Class

B.

Abstract

C.

Interface

D.

Final

Question 32

Which sentence describes the following regular expression match?

preg_match('/^\d*(?:\.[0-9]+)?$/', $test);

Options:

A.

It matches float numbers with thousand separators.

B.

It matches float numbers without thousand separators.

C.

It matches binary integer numbers.

D.

It matches any string.

E.

It does not match anything

Page: 1 / 22
Total 219 questions