MultipleChoice
What is the output of the following code?
$a = 3;
switch ($a) {
case 1: echo 'one'; break;
case 2: echo 'two'; break;
default: echo 'four'; break;
case 3: echo 'three'; break;
}
OptionsMultipleChoice
What is the output of the following code?
$a = 'a'; $b = 'b';
echo isset($c) ? $a.$b.$c : ($c = 'c').'d';
OptionsMultipleChoice
What is the output of the following code?
echo "1" + 2 * "0x02";
OptionsMultipleChoice
What is the output of the following code?
echo "22" + "0.2", 23 . 1;
OptionsFillInTheBlank
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"
FillInTheBlank
Which PHP function is used to validate whether the contents of $_FILES['name']['tmp_name'] have really been uploaded via HTTP?
MultipleChoice
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';
OptionsMultipleChoice
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';
OptionsMultipleChoice
What is the output of the following code?
$a = array('a', 'b'=>'c');
echo property_exists((object) $a, 'a')?'true':'false';
echo '-';
echo property_exists((object) $a, 'b')?'true':'false';
OptionsMultipleChoice
Consider the following XML code:
Which of the following SimpleXML calls prints the name of the second book?
(Let $xml = simplexml_load_file("books.xml"); .) (Choose 2)
Options