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

Zend 200-550 Zend Certified PHP Engineer Exam Practice Test

Demo: 33 questions
Total 223 questions

Zend Certified PHP Engineer Questions and Answers

Question 1

What is the output of this code?

$world = 'world';

echo <<<'TEXT'

hello $world

TEXT;

Options:

A.

hello world

B.

hello $world

C.

PHP Parser error

Question 2

You want to allow your users to submit HTML code in a form, which will then be displayed as real code and not affect your page layout. Which function do you apply to the text, when displaying it? (Choose 2)

Options:

A.

strip_tags()

B.

htmlentities()

C.

htmltidy()

D.

htmlspecialchars()

E.

showhtml()

Question 3

What is the output of the following code?

class C {

public $x = 1;

function __construct() { ++$this->x; }

function __invoke() { return ++$this->x; }

function __toString() { return (string) --$this->x; }

}

$obj = new C();

echo $obj();

Options:

A.

0

B.

1

C.

2

D.

3

Question 4

Which of the following statements is true?

Options:

A.

All PHP database extensions support prepared statements

B.

All PHP database extensions come with their own special helper functions to escape user data to be used in dynamic SQL queries

C.

All PHP database extensions provide an OOP interface

D.

All PHP database extensions appear in the output of php -m , if installed and enabled

Question 5

What is the difference between "print" and "echo"?

Options:

A.

There is no difference.

B.

Print has a return value, echo does not

C.

Echo has a return value, print does not

D.

Print buffers the output, while echo does not

E.

None of the above

Question 6

Which of the following is NOT true about PHP traits? (Choose 2)

Options:

A.

Multiple traits can be used by a single class.

B.

A trait can implement an interface.

C.

A trait can declare a private variable.

D.

Traits are able to be auto-loaded.

E.

Traits automatically resolve conflicts based on definition order.

Question 7

Your application uses PHP to accept and process file uploads. It fails to upload a file that is 5 MB in size, although upload_max_filesize is set to "10M". Which of the following configurations could be responsible for this outcome? (Choose 2)

Options:

A.

The PHP configuration option post_max_size is set to a value that is too small

B.

The web server is using an incorrect encoding as part of the HTTP response sent to the client

C.

The browser uses an incorrect encoding as part of the HTTP request sent to the server

D.

The hidden form field MAX_FILE_SIZE was set to a value that is too small

E.

PHP cannot process file uploads larger than 4 MB

Question 8

Consider the following code. What change must be made to the class for the code to work as written?

class Magic {

protected $v = array("a" => 1, "b" => 2, "c" => 3);

public function __get($v) {

return $this->v[$v];

}

}

$m = new Magic();

$m->d[] = 4;

echo $m->d[0];

Options:

A.

Nothing, this code works just fine.

B.

Add __set method doing $this->v[$var] = $val

C.

Rewrite __get as: public function __get(&$v)

D.

Rewrite __get as: public function &__get($v)

E.

Make __get method static

Question 9

Which of the following PHP values may NOT be encoded to a JavaScript literal using PHP's ext/json capabilities?

Options:

A.

'Hello, world!'

B.

function(){ alert("Hello, world!"); }

C.

array('Hello, world!')

D.

array('message' => 'Hello, world!')

Question 10

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

Options:

A.

File system permissions

B.

File is outside of open_basedir

C.

File is inside the /tmp directory.

D.

PHP is running in CGI mode.

Question 11

What is the output of the following code?

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

echo property_exists((object) $a, 'a')?'true':'false';

echo '-';

echo property_exists((object) $a, 'b')?'true':'false';

Options:

A.

false-false

B.

false-true

C.

true-false

D.

true-true

Question 12

Which parts of the text are matched in the following regular expression?

$text = <<

The big bang bonged under the bung.

EOT;

preg_match_all('@b.n?g@', $text, $matches);

Options:

A.

bang bong bung

B.

bang bonged bung

C.

big bang bong bung

D.

big bang bung

Question 13

What would be the output of the following code?

namespace MyFramework\DB;

class MyClass {

static function myName() {

return __METHOD__;

}

}

print MyClass::myName();

Options:

A.

MyFramework\DB\myName

B.

MyFramework\DB\MyClass\myName

C.

MyFramework\DB\MyClass::myName

D.

MyClass::myName

Question 14

What is the output of the following code?

function increment (&$val)

{

return $val + 1;

}

$a = 1;

echo increment ($a);

echo increment ($a);

Options:

Question 15

What function can be used to retrieve an array of current options for a stream context?

Options:

A.

stream_context_get_params

B.

stream_context_get_default

C.

stream_context_get_options

D.

The 'options' element of the stream_get_meta_data return value

Question 16

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 17

You want to parse a URL into its single parts. Which function do you choose?

Options:

A.

parse_url()

B.

url_parse()

C.

get_url_parts()

D.

geturlparts()

Question 18

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

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

Options:

A.

1

B.

2

C.

3

D.

4

Question 19

Which of the following code snippets is correct? (Choose 2)

Options:

A.

interface Drawable {

abstract function draw();

}

B.

interface Point {

function getX();

function getY();

}

C.

interface Line extends Point {

function getX2();

function getY2();

}

D.

interface Circle implements Point {

function getRadius();

}

Question 20

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 21

What is the name of the header used to require HTTP authentication?

Options:

A.

Authorization-Required

B.

WWW-Authenticate

C.

HTTP-Authenticate

D.

Authentication-Required

E.

HTTP-Auth

Question 22

What will the following code print out?

$str = '✔ one of the following';

echo str_replace('✔', 'Check', $str);

Options:

A.

Check one of the following

B.

one of the following

C.

✔ one of the following

Question 23

How should you track errors on your production website?

Options:

A.

Enabling display_errors

B.

Enabling log_errors

C.

Having a site-wide exception handler

D.

Setting error_reporting to E_ALL & ~E_NOTICE

Question 24

What is the output of the following code?

class Number {

private $v;

private static $sv = 10;

public function __construct($v) { $this->v = $v; }

public function mul() {

return static function ($x) {

return isset($this) ? $this->v*$x : self::$sv*$x;

};

}

}

$one = new Number(1);

$two = new Number(2);

$double = $two->mul();

$x = Closure::bind($double, null, 'Number');

echo $x(5);

Options:

A.

5

B.

10

C.

50

D.

Fatal error

Question 25

Which PHP function is used to validate whether the contents of $_FILES['name']['tmp_name'] have really been uploaded via HTTP?

Options:

Question 26

An HTML form contains this form element:

When this form is submitted, the following PHP code gets executed:

move_uploaded_file(

$_FILES['myFile']['tmp_name'],

'uploads/' . $_FILES['myFile']['name']

);

Which of the following actions must be taken before this code may go into production? (Choose 2)

Options:

A.

Check with is_uploaded_file() whether the uploaded file $_FILES['myFile']['tmp_name'] is valid

B.

Sanitize the file name in $_FILES['myFile']['name'] because this value is not consistent among web browsers

C.

Check the charset encoding of the HTTP request to see whether it matches the encoding of the uploaded file

D.

Sanitize the file name in $_FILES['myFile']['name'] because this value could be forged

E.

Use $HTTP_POST_FILES instead of $_FILES to maintain upwards compatibility

Question 27

Which PHP function retrieves a list of HTTP headers that have been sent as part of the HTTP response or are ready to be sent?

Options:

A.

header()

B.

headers()

C.

headers_list()

D.

headers_sent()

E.

getresponseheaders()

Question 28

The following form is loaded in a browser and submitted, with the checkbox activated:

In the server-side PHP code to deal with the form data, what is the value of $_POST['accept'] ?

Options:

A.

accept

B.

ok

C.

true

D.

on

Question 29

The XML document below has been parsed into $xml via SimpleXML. How can the value of tag accessed?

Value

Options:

A.

$xml->bar['foo']

B.

$xml->bar->foo

C.

$xml['document']['bar']['foo']

D.

$xml->document->bar->foo

E.

$xml->getElementByName('foo');

Question 30

Which of the following may be used in conjunction with CASE inside a SWITCH statement?

Options:

A.

A scalar

B.

An expression

C.

A boolean

D.

All of the above

Question 31

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 32

Which PHP function sets a cookie whose value does not get URL encoded when sending it to the browser?

Options:

Question 33

Which of the following does NOT help to protect against session hijacking and fixation attacks?

Options:

A.

Use SSL and set the $secure cookie parameter to true .

B.

Set the session.use_only_cookies php.ini parameter to 1 .

C.

Set the session.cookie_lifetime php.ini parameter to 0 .

D.

Protect against XSS vulnerabilities in the application.

E.

Rotate the session id on successful login and logout using session_regenerate_id()

Demo: 33 questions
Total 223 questions