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

Zend 200-550 Zend Certified PHP Engineer Exam Practice Test

Page: 1 / 22
Total 223 questions

Zend Certified PHP Engineer Questions and Answers

Question 1

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 2

From your PHP application, how can you send the same header twice, but with different values?

Options:

A.

Set the second argument of the header() function to false

B.

PHP does that automatically

C.

You may only send a particular type of header once

D.

Use the header_add() function

Question 3

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 4

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 5

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'.

Question 6

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

Question 7

What DOMElement method should be used to check for availability of a non-namespaced attribute?

Options:

A.

getAttributeNS()

B.

getAttribute()

C.

hasAttribute()

D.

hasAttributeNS()

Question 8

Which of these elements can be encapsulated by namespaces and made accessible from the outside?

Options:

A.

Only classes

B.

Classes, functions and constants

C.

Classes, functions, constants and variables

Question 9

What is cached by an opcode cache?

Options:

A.

Compiled PHP code

B.

Native PHP extensions

C.

Data sent to the client

D.

Data received from the database

Question 10

Which is the most efficient way to determine if a key is present in an array, assuming the array has no NULL values?

Options:

A.

in_array('key', array_keys($a))

B.

isset($a['key'])

C.

array_key_exists('key', $a)

D.

None of the above

Question 11

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 12

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 13

Is the following code vulnerable to SQL Injection ($mysqli is an instance of the MySQLi class)?

$age = $mysqli->real_escape_string($_GET['age']);

$name = $mysqli->real_escape_string($_GET['name']);

$query = "SELECT * FROM `table` WHERE name LIKE '$name' AND age = $age";

$results = $mysqli->query($query);

Options:

A.

No, the code is fully protected from SQL Injection.

B.

Yes, because the $name variable is improperly escaped.

C.

Yes, because the $name variable and the $age variable is improperly escaped.

D.

Yes, because the $age variable is improperly escaped.

E.

Yes, because you cannot prevent SQL Injection when using MySQLi

Question 14

What will be the output of the following code?

$a = array(0, 1, 2 => array(3, 4));

$a[3] = array(4, 5);

echo count($a, 1);

Options:

A.

4

B.

5

C.

8

D.

None of the above

Question 15

Which of the following statements about SOAP is NOT true?

Options:

A.

SOAP is also a request-/response-based protocol.

B.

SOAP can be transported using SMTP, HTTP and other protocols.

C.

SOAP requires developers to use WSDL.

D.

SOAP traffic via HTTP can be encrypted and compressed just like other HTTP requests.

Question 16

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 17

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 18

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

Question 19

An unbuffered database query will: (Choose 2)

Options:

A.

Return the first data faster

B.

Return all data faster

C.

Free connection faster for others scripts to use

D.

Use less memory

Question 20

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

Question 21

How can a SimpleXML object be converted to a DOM object?

Options:

A.

dom_import_simplexml()

B.

dom_export_simplexml()

C.

simplexml_import_dom()

D.

SimpleXML2Dom()

E.

None of the above.

Question 22

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

Question 23

Given the following DateTime objects, what can you use to compare the two dates and indicate that $date2 is the later of the two dates?

$date1 = new DateTime('2014-02-03');

$date2 = new DateTime('2014-03-02');

Options:

A.

$date2 > $date1

B.

$date2 < $date1

C.

$date1->diff($date2) < 0

D.

$date1->diff($date2) > 0

Question 24

Which MIME type is always sent by a client if a JPEG file is uploaded via HTTP?

Options:

A.

image/jpeg

B.

image/jpg

C.

image/pjpeg

D.

Depends on the client system

Question 25

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

Question 26

What is the name of the key in $_FILES['name'] that contains the number of bytes of the uploaded file?

Options:

Question 27

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];

Question 28

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

Question 29

What is the result of the following bitwise operation in PHP?

1 ^ 2

Options:

A.

1

B.

3

C.

2

D.

4

E.

-1

Question 30

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

Question 31

What is the result of the following code?

class T

{

const A = 42 + 1;

}

echo T::A;

Options:

A.

42

B.

43

C.

Parse error

Question 32

In the following code, which classes can be instantiated?

abstract class Graphics {

abstract function draw($im, $col);

}

abstract class Point1 extends Graphics {

public $x, $y;

function __construct($x, $y) {

$this->x = $x;

$this->y = $y;

}

function draw($im, $col) {

ImageSetPixel($im, $this->x, $this->y, $col);

}

}

class Point2 extends Point1 { }

abstract class Point3 extends Point2 { }

Options:

A.

Graphics

B.

Point1

C.

Point2

D.

Point3

E.

None, the code is invalid

Question 33

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

Page: 1 / 22
Total 223 questions