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';
A. false
B. true
正解:A
質問 2:
What is the output of this code?
$world = 'world'; echo <<<'TEXT' hello $world
TEXT;
A. hello world
B. hello $world
C. PHP Parser error
正解:C
質問 3:
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. __get/__set
C. ArrayAccess
D. Iterator
正解:A
質問 4:
Which class of HTTP status codes is used for server error conditions?
A. 3XX
B. 4XX
C. 5XX
D. 2XX
正解:C
質問 5:
How many elements does the $matches array contain after the following function call is performed?
preg_match('/^(\d{1,2}([a-z]+))(?:\s*)\S+ (?=201[0-9])/', '21st March 2014', $matches);
A. 4
B. 1
C. 3
D. 2
正解:C
質問 6:
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. Add __set method doing $this->v[$var] = $val
B. Nothing, this code works just fine.
C. Rewrite __get as: public function &__get($v)
D. Make __get method static
E. Rewrite __get as: public function __get(&$v)
正解:C
質問 7:
Your public web application needs to provide access to binary files for registered users only. How would you achieve this?
A. PHP is used for service HTML content, not binary content
B. Use PHP to send the file to the client, using the header() function to set appropriate HTTP headers
C. Redirect to the file which resides in the server's document root
D. Host the files on a public external file sharing service.
正解:B
Matsuki -
200-550問題集の九割が試験の問題にも出ていて凄かった。本当に助けになってました。