Which interfaces could class C implement in order to allow each statement in the following code to work? (Choose 2)
$obj = new C();
foreach ($obj as $x => $y) {
echo $x, $y;
Answer : A,C
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';
Answer : B
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';
Answer : B
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';
Answer : B
Assuming UTF-8 encoding, what is the value of $count?
$data = '$12';
$count = strlen($data);
Answer : C
What is the output of this code?
$world = 'world';
echo <<<'TEXT'
hello $world
TEXT;
Answer : C
Given a php.ini setting of -
default_charset = utf-8
what will the following code print in the browser?
header('Content-Type: text/html; charset=iso-8859-1');
echo '✂✔✝';
Answer : A
What will the following code print out?
$str = '✔ one of the following';
echo str_replace('✔', 'Check', $str);
Answer : A
What is the pattern modifier for handling UTF-8 encoded preg_* functionality?
Answer : B
What is the output of the following code?
$text = 'This is text';
$text1 = <<<'TEXT'
$text
TEXT;
$text2 = <<<TEXT
$text1
TEXT;
echo "$text2";
Answer : B
Your public web application needs to provide access to binary files for registered users only. How would you achieve this?
Answer : C
What content-type is required when sending an HTTP POST using JavaScript to ensure that PHP can access the data?
Answer : A
From your PHP application, how can you send the same header twice, but with different values?
Answer : A
Which class of HTTP status codes is used for server error conditions?
Answer : D