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

Zend 200-550 - Zend Certified PHP Engineer

Page: 4 / 7
Total 223 questions

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

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

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

A.

autoload()

B.

__autoload()

C.

__catch()

D.

load()

E.

loadClass()

SimpleXML provides the ability to iterate over items in an XML document, as well as access items within it as if they were object properties. When creating your own classes to access data, implementing which of the following would NOT achieve this goal?

A.

__toString

B.

Iterator

C.

__get/__set

D.

ArrayAccess

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

A.

String

B.

Integer

C.

Array

D.

Any class or interface type

E.

All of the above

When a browser requests an image identified by an img tag, it never sends a Cookie header.

A.

TRUE

B.

FALSE

What is the output of the following code?

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

A.

123

B.

213

C.

142

D.

214

E.

Syntax error

In order to create an object storage where each object would be stored only once, you may use which of the following? (Choose 2)

A.

SplFixedArray

B.

SplObjectStorage

C.

SplString

D.

spl_object_hash

E.

spl_same_object

What is the preferred method for preventing SQL injection?

A.

Always using prepared statements for all SQL queries.

B.

Always using the available database-specific escaping functionality on all variables prior to building the SQL query.

C.

Using addslashes() to escape variables to be used in a query.

D.

Using htmlspecialchars() and the available database-specific escaping functionality to escape variables to be used in a query.

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;

A.

Parse error

B.

3.14

C.

PI

D.

T::PI

What is the output of the following code?

class A {

public $a = 1;

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

public function mul() {

return function($x) {

return $this->a*$x;

};

}

}

$a = new A(2);

$a->mul = function($x) {

return $x*$x;

};

$m = $a->mul();

echo $m(3);

A.

9

B.

6

C.

0

D.

3