Spring Sale Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: pass65

200-550 Zend Certified PHP Engineer Questions and Answers

Questions 4

Given the following code, what is correct?

function f(stdClass & $x = NULL) { $x = 42; }

$z = new stdClass;

f($z);

var_dump($z);

Options:

A.

Error: Typehints cannot be NULL

B.

Error: Typehints cannot be references

C.

Result is NULL

D.

Result is object of type stdClass

E.

Result is 42

Buy Now
Questions 5

Which options do you have in PHP to set the expiry date of a session?

Options:

A.

Set the session.duration directive in php.ini

B.

Set session cookie expiry date locally via session_set_cookie_params()

C.

Set session expiry date locally via session_cache_expire()

D.

None of the above

Buy Now
Questions 6

Which constant must be passed as the second argument to htmlentities() to convert single quotes (') to HTML entities?

Options:

A.

TRUE

B.

FALSE

C.

ENT_QUOTES

D.

ENT_NOQUOTES

E.

ENT_COMPAT

Buy Now
Questions 7

Which of these databases is NOT supported by a PDO driver?

Options:

A.

Microsoft SQL Server

B.

SQLite

C.

Microsoft Access

D.

Berkeley DB

Buy Now
Questions 8

Type hinting in PHP allows the identification of the following variable types: (Choose 2)

Options:

A.

String

B.

Integer

C.

Array

D.

Any class or interface type

E.

All of the above

Buy Now
Questions 9

What is the output of the following code?

echo '1' . (print '2') + 3;

Options:

A.

123

B.

213

C.

142

D.

214

E.

Syntax error

Buy Now
Questions 10

Which of the following PHP functions can be used to set the HTTP response code? (Choose 2)

Options:

A.

header_add()

B.

header()

C.

http_set_status()

D.

http_response_code()

E.

http_header_set()

Buy Now
Questions 11

Which of the following is an invalid DOM save method?

Options:

A.

save()

B.

saveFile()

C.

saveXML()

D.

saveHTML()

E.

saveHTMLFile()

Buy Now
Questions 12

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()

Buy Now
Questions 13

What is the name of the PHP function used to automatically load non-yet defined classes?

Options:

A.

autoload()

B.

__autoload()

C.

__catch()

D.

load()

E.

loadClass()

Buy Now
Questions 14

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();

}

Buy Now
Questions 15

Given a JSON-encoded string, which code sample correctly indicates how to decode the string to native PHP values?

Options:

A.

$json = new Json($jsonValue); $value = $json- > decode();

B.

$value = Json::decode($jsonValue);

C.

$value = json_decode($jsonValue);

D.

$value = Json::fromJson($jsonValue);

Buy Now
Questions 16

Which of the following tasks can be achieved by using magic methods? (Choose 3)

Options:

A.

Initializing or uninitializing object data

B.

Creating a new stream wrapper

C.

Creating an iterable object

D.

Processing access to undefined methods or properties

E.

Overloading operators like +, *, etc.

F.

Converting objects to string representation

Buy Now
Questions 17

Given a PHP value, which sample shows how to convert the value to JSON?

Options:

A.

$string = json_encode($value);

B.

$string = Json::encode($value);

C.

$json = new Json($value); $string = $json- > __toString();

D.

$value = (object) $value; $string = $value- > __toJson();

Buy Now
Questions 18

What is the output of the following code?

class a

{

public $val;

}

function renderVal (a $a)

{

if ($a) {

echo $a- > val;

}

}

renderVal (null);

Options:

A.

A syntax error in the function declaration line

B.

An error, because null is not an instance of 'a'

C.

Nothing, because a null value is being passed to renderVal()

D.

NULL

Buy Now
Questions 19

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

Buy Now
Questions 20

Which of these statements about PDO is NOT true?

Options:

A.

PDO has built-in support for Large Objects (LOBs).

B.

Placeholders within PDO prepared statements need to be named.

C.

When something goes wrong, PDO can throw an instance of its own exception class.

D.

PDO does not emulate missing database features.

Buy Now
Questions 21

What is the output of the following code?

class Bar {

private $a = 'b';

public $c = 'd';

}

$x = (array) new Bar();

echo array_key_exists('a', $x) ? 'true' : 'false';

echo '-';

echo array_key_exists('c', $x) ? 'true' : 'false';

Options:

A.

false-false

B.

false-true

C.

true-false

D.

true-true

Buy Now
Questions 22

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()

Buy Now
Questions 23

Consider the following two files. When you run test.php, what would the output look like?

test.php:

include "MyString.php";

print ",";

print strlen("Hello world!");

MyString.php:

namespace MyFramework\String;

function strlen($str)

{

return \strlen($str)*2; // return double the string length

}

print strlen("Hello world!")

Options:

A.

12,12

B.

12,24

C.

24,12

D.

24,24

E.

PHP Fatal error: Cannot redeclare strlen()

Buy Now
Questions 24

What is the output of the following code?

function z($x) {

return function ($y) use ($x) {

return str_repeat($y, $x);

};

}

$a = z(2);

$b = z(3);

echo $a(3) . $b(2);

Options:

A.

22333

B.

33222

C.

33322

D.

222333

Buy Now
Questions 25

Which of the following functions will allow identifying unique values inside an array?

Options:

A.

array_unique_values

B.

array_distinct

C.

array_count_values

D.

array_intersect

E.

array_values

Buy Now
Questions 26

What is the output of the following code?

class Foo Implements ArrayAccess {

function offsetExists($k) { return true;}

function offsetGet($k) {return 'a';}

function offsetSet($k, $v) {}

function offsetUnset($k) {}

}

$x = new Foo();

echo array_key_exists('foo', $x)?'true':'false';

Options:

A.

true

B.

false

Buy Now
Questions 27

What is the output of the following code?

function increment ($val)

{

++$val;

}

$val = 1;

increment ($val);

echo $val;

Options:

Buy Now
Questions 28

When a query that is supposed to affect rows is executed as part of a transaction, and reports no affected rows, it could mean that: (Choose 2)

Options:

A.

The transaction failed

B.

The transaction affected no lines

C.

The transaction was rolled back

D.

The transaction was committed without error

Buy Now
Questions 29

Given the following DateTime object, which sample will NOT alter the date to the value '2014-02-15'?

$date = new DateTime('2014-03-15');

Options:

A.

$date- > sub(new DateInterval('P1M'));

B.

$date- > setDate(2014, 2, 15);

C.

$date- > modify('-1 month');

D.

$date- > diff(new DateInterval('-P1M'));

Buy Now
Questions 30

What is the result of the following code?

define('PI', 3.14);

class T

{

const PI = PI;

}

class Math

{

const PI = T::PI;

}

echo Math::PI;

Options:

A.

Parse error

B.

3.14

C.

PI

D.

T::PI

Buy Now
Questions 31

What is the output of the following code?

class Base {

protected static function whoami() {

echo "Base ";

}

public static function whoareyou() {

static::whoami();

}

}

class A extends Base {

public static function test() {

Base::whoareyou();

self::whoareyou();

parent::whoareyou();

Options:

A.

:whoareyou();

static::whoareyou();

}

public static function whoami() {

echo "A ";

}

}

class B extends A {

public static function whoami() {

echo "B ";

}

}

B.

:test();

C.

B B B B B

D.

Base A Base A B

E.

Base B B A B

F.

Base B A A B

Buy Now
Questions 32

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()

Buy Now
Questions 33

What DOM method is used to load HTML files?

Options:

A.

load()

B.

loadXML()

C.

loadHTML()

D.

loadHTMLFile()

Buy Now
Questions 34

What is the output of the following code?

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

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

Options:

A.

abc

B.

cd

C.

0d

Buy Now
Questions 35

Consider the following XML code:

< ?xml version="1.0" encoding="utf-8"? >

< books >

< book id="1" > PHP 5.5 in 42 Hours < /book >

< book id="2" > Learning PHP 5.5 The Hard Way < /book >

< /books >

Which of the following SimpleXML calls prints the name of the second book?

(Let $xml = simplexml_load_file("books.xml"); .) (Choose 2)

Options:

A.

echo $xml- > books- > book[2];

B.

echo $xml- > books- > book[1];

C.

echo $xml- > book[1];

D.

echo $xml- > xpath("/books/book[@id=2]");

E.

$c = $xml- > children(); echo $c[1];

Buy Now
Questions 36

Which of the following is NOT possible using reflection?

Options:

A.

Analysing of nearly any aspect of classes and interfaces

B.

Analysing of nearly any aspect of functions

C.

Adding class methods

D.

Implement dynamic construction (new with variable class name)

Buy Now
Questions 37

What is the output of the following code?

echo "1" + 2 * "0x02";

Options:

A.

1

B.

3

C.

5

D.

20

E.

7

Buy Now
Questions 38

What is the output of the following code?

try {

class MyException extends Exception {};

try {

throw new MyException;

}

catch (Exception $e) {

echo "1:";

throw $e;

}

catch (MyException $e) {

echo "2:";

throw $e;

}

}

catch (Exception $e) {

echo get_class($e);

}

Options:

A.

A parser error, try cannot be followed by multiple catch

B.

1:

C.

2:

D.

1:Exception

E.

1:MyException

F.

2:MyException

G.

MyException

Buy Now
Questions 39

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

Buy Now
Questions 40

Consider the following code. What can be said about the call to file_get_contents?

$getdata = "foo=bar";

$opts = array('http' = >

array(

'method' = > 'POST',

'header' = > 'Content-type: application/x-www-form-urlencoded',

'content' = > $getdata

)

);

$context = stream_context_create($opts);

$result = file_get_contents('http://example.com/submit.php', false, $context);

Options:

A.

A GET request will be performed on http://example.com/submit.php

B.

A POST request will be performed on http://example.com/submit.php

C.

An error will be displayed

Buy Now
Questions 41

Which line of code can be used to replace the INSERT comment in order to output "hello"?

class C {

public $ello = 'ello';

public $c;

public $m;

function __construct($y) {

$this- > c = static function($f) {

// INSERT LINE OF CODE HERE

};

$this- > m = function() {

return "h";

};

}

}

$x = new C("h");

$f = $x- > c;

echo $f($x- > m);

Options:

A.

return $this- > m() . "ello";

B.

return $f() . "ello";

C.

return "h". $this- > ello;

D.

return $y . "ello";

Buy Now
Questions 42

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

Buy Now
Questions 43

Consider the following table data and PHP code. What is the outcome?

Table data (table name "users" with primary key "id"):

id name email

------- ----------- -------------------

1 anna alpha@example.com

2 betty beta@example.org

3 clara gamma@example.net

5 sue sigma@example.info

PHP code (assume the PDO connection is correctly established):

$dsn = 'mysql:host=localhost;dbname=exam';

$user = 'username';

$pass = '********';

$pdo = new PDO($dsn, $user, $pass);

$cmd = "SELECT * FROM users WHERE id = :id";

$stmt = $pdo- > prepare($cmd);

$id = 3;

$stmt- > bindParam('id', $id);

$stmt- > execute();

$stmt- > bindColumn(3, $result);

$row = $stmt- > fetch(PDO::FETCH_BOUND);

Options:

A.

The database will return no rows.

B.

The value of $row will be an array.

C.

The value of $result will be empty.

D.

The value of $result will be 'gamma@example.net'.

Buy Now
Questions 44

What is the output of the following code?

$first = "second";

$second = "first";

echo $$$first;

Options:

A.

"first"

B.

"second"

C.

an empty string

D.

an error

Buy Now
Questions 45

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

Options:

Buy Now
Questions 46

What is the output of the following code?

function ratio ($x1 = 10, $x2)

{

if (isset ($x2)) {

return $x2 / $x1;

}

}

echo ratio (0);

Options:

A.

0

B.

An integer overflow error

C.

A warning, because $x1 is not set

D.

A warning, because $x2 is not set

E.

A floating-point overflow error

F.

Nothing

Buy Now
Questions 47

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

Buy Now
Questions 48

What is the name of the method that can be used to provide read access to virtual properties in a class?

Options:

A.

__call()

B.

__get()

C.

__set()

D.

__wakeup()

E.

__fetch()

Buy Now
Questions 49

Which string will be returned by the following function call?

$test = '/etc/conf.d/wireless';

substr($test, strrpos($test, '/')); // note that strrpos() is being called, and not strpos()

Options:

A.

""

B.

"/wireless"

C.

"wireless"

D.

"/conf.d/wireless"

E.

"/etc"

Buy Now
Questions 50

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

Buy Now
Questions 51

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!')

Buy Now
Questions 52

Which of the following expressions will evaluate to a random value from an array below?

$array = array("Sue","Mary","John","Anna");

Options:

A.

array_rand($array);

B.

array_rand($array, 1);

C.

shuffle($array);

D.

$array[array_rand($array)];

E.

array_values($array, ARRAY_RANDOM);

Buy Now
Questions 53

Given a DateTime object that is set to the first second of the year 2014, which of the following samples will correctly return a date in the format '2014-01-01 00:00:01'?

Options:

A.

$datetime- > format('%Y-%m-%d %h:%i:%s')

B.

$datetime- > format('%Y-%m-%d %h:%i:%s', array('year', 'month', 'day', 'hour', 'minute', 'second'))

C.

$datetime- > format('Y-m-d H:i:s')

D.

$date = date('Y-m-d H:i:s', $datetime);

Buy Now
Questions 54

Which of the following will NOT instantiate a DateTime object with the current timestamp?

Options:

A.

$date = new DateTime();

B.

$date = new DateTime('@' . time());

C.

$date = new DateTime('now');

D.

$date = new DateTime(time());

Buy Now
Questions 55

Which class of HTTP status codes is used for server error conditions?

Options:

A.

2XX

B.

3XX

C.

4XX

D.

5XX

Buy Now
Questions 56

One common security risk is exposing error messages directly in the browser. Which PHP configuration directive can be disabled to prevent this?

Options:

A.

html_display

B.

error_reporting

C.

display_errors

D.

error_log

E.

ignore_repeated_errors

Buy Now
Questions 57

Which PHP function is used to validate whether the contents of $_FILES['name']['tmp_name'] have really been uploaded via HTTP, and also save the contents into another folder?

Options:

Buy Now
Questions 58

What will be the result of the following operation?

$a = array_merge([1,2,3] + [4= > 1,5,6]);

echo $a[2];

Options:

A.

4

B.

3

C.

2

D.

false

E.

Parse error

Buy Now
Questions 59

What super-global should be used to access information about uploaded files via a POST request?

Options:

A.

$_SERVER

B.

$_ENV

C.

$_POST

D.

$_FILES

E.

$_GET

Buy Now
Questions 60

Which of the following statements about anonymous functions in PHP are NOT true? (Choose 2)

Options:

A.

Anonymous functions can be bound to objects

B.

Anonymous functions created within object context are always bound to that object

C.

Assigning closure to a property of an object binds it to that object

D.

Methods bind() and bindTo() of the Closure object provide means to create closures with different binding and scope

E.

Binding defines the value of $this and the scope for a closure

Buy Now
Questions 61

What is the output of the following code?

$text = 'This is text';

$text1 = < < < 'TEXT'

$text

TEXT;

$text2 = < < < TEXT

$text1

TEXT;

echo "$text2";

Options:

A.

This is text

B.

$text

C.

$text1

D.

$text2

Buy Now
Questions 62

Consider the following code. Which keyword should be used in the line marked with "KEYWORD" instead of "self" to make this code work as intended?

abstract class Base {

protected function __construct() {

}

public static function create() {

return new self(); // KEYWORD

}

abstract function action();

}

class Item extends Base {

public function action() { echo __CLASS__; }

}

$item = Item::create();

$item- > action(); // outputs "Item"

Options:

Buy Now
Questions 63

What is the output of the following code?

$f = function () { return "hello"; };

echo gettype($f);

Options:

A.

hello

B.

string

C.

object

D.

function

Buy Now
Questions 64

Which of the following is NOT a requirement for file uploads to work?

Options:

A.

The PHP directive file_uploads must be set to On

B.

The form's method attribute must be set to "post"

C.

The form must include a hidden input element with the name set to "MAX_FILE_SIZE"

D.

The form's enctype attribute must be set to "multipart/form-data"

Buy Now
Questions 65

Which of the following are NOT acceptable ways to create a secure password hash in PHP? (Choose 2)

Options:

A.

md5()

B.

hash_pbkdf2()

C.

password_hash()

D.

crypt()

E.

openssl_digest()

Buy Now
Questions 66

What function can reverse the order of values in an array so that keys are preserved?

Options:

A.

array_flip()

B.

array_reverse()

C.

rsort()

D.

krsort()

E.

array_multisort()

Buy Now
Exam Code: 200-550
Exam Name: Zend Certified PHP Engineer
Last Update: Apr 30, 2026
Questions: 223

PDF + Testing Engine

$63.52  $181.49

Testing Engine

$50.57  $144.49
buy now 200-550 testing engine

PDF (Q&A)

$43.57  $124.49
buy now 200-550 pdf