What is the output of the following code?
What is the output of the following code? $f = function () { return “hello”; }; echo gettype($f);
What is the output of the following code?
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();
Which keyword should be used in the line marked with "KEYWORD" instead of "self" to make t
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”
Which SPL class implements fixed-size storage?
Which SPL class implements fixed-size storage?
which of the following?
In order to create an object storage where each object would be stored only once, you may
use which of the following? (Choose 2)
What is the output of the following code?
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();
Late static binding is used in PHP to:
Late static binding is used in PHP to:
What is the output of the following code?
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’);
Which of the following tasks can be achieved by using magic methods?
Which of the following tasks can be achieved by using magic methods? (Choose 3)
How should class MyObject be defined for the following code to work properly?
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);