Zend Certified PHP Engineer v6.0

Page:    1 / 15   
Exam contains 223 questions

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

  • A. 0
  • B. 1
  • C. 2
  • D. 3


Answer : D

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"



Answer : static

Which SPL class implements fixed-size storage?



Answer : SplFixedArray

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


Answer : BD

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

  • 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


Answer : C

Late static binding is used in PHP to:

  • A. Load dynamic libraries and extensions at runtime
  • B. Use caller class information provided in static method call
  • C. Resolve undefined class names by automatically including needed files
  • D. Find proper method to call according to the call arguments


Answer : B

What is the output of the following code?
class Test {
public function __call($name, $args)
call_user_func_array(array('static', "test$name"), $args);
public function testS($l) {
echo "$l,";
class Test2 extends Test {
public function testS($l) {
echo "$l,$l,";
$test = new Test2();
$test->S('A');

  • A. A,
  • B. A,A,
  • C. A,A,A,
  • D. PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback


Answer : B

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

  • 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


Answer : ADF

How should class MyObject be defined for the following code to work properly? Assume
$array is an array and MyObject is a user-defined class.
$obj = new MyObject();
array_walk($array, $obj);

  • A. MyObject should extend class Closure
  • B. MyObject should implement interface Callable
  • C. MyObject should implement method __call
  • D. MyObject should implement method __invoke


Answer : D

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


Answer : D

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


Answer : A

Which of the following is used to find all PHP files under a certain directory?

  • A. PHPIterator
  • B. RecursiveTreeIterator
  • C. RecursiveDirectoryIterator
  • D. SplTempFileObject


Answer : C

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



Answer : is_uploaded_file(), is_uploaded_file

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?



Answer : move_uploaded_file(), move_uploaded_file

What is the name of the key for the element in $_FILES['name'] that contains the provisional name of the uploaded file?



Answer : tmp_name

Page:    1 / 15   
Exam contains 223 questions

Talk to us!


Have any questions or issues ? Please dont hesitate to contact us

Certlibrary.com is owned by MBS Tech Limited: Room 1905 Nam Wo Hong Building, 148 Wing Lok Street, Sheung Wan, Hong Kong. Company registration number: 2310926
Certlibrary doesn't offer Real Microsoft Exam Questions. Certlibrary Materials do not contain actual questions and answers from Cisco's Certification Exams.
CFA Institute does not endorse, promote or warrant the accuracy or quality of Certlibrary. CFA® and Chartered Financial Analyst® are registered trademarks owned by CFA Institute.
Terms & Conditions | Privacy Policy