<?phpfunction myfunction($a, $b = true){if($a && !$b) {echo "Hello, World!\n";}}$s = array(0 => "my",1 => "call",2 => '$function',3 => ' ',4 => "function",5 => '$a',6 => '$b',7 => 'a',8 => 'b',9 => '');$a = true;$b = false;/* Group A */$name = $s[?].$s[?].$s[?].$s[?].$s[?].$s[?];/* Group B */$name(${$s[?]}, ${$s[?]});?>
The only answer that really fits the bill is A. A script doesn’t necessarily terminate when itreaches the end of any file other than the main one—so the “current” file could be externallyincluded and not cause the script to terminate at its end. As far as PHP and Apache crashes,they can hardly be considered “clean” ways to terminate a script.
<?phpclass my_class{var $my_value = array();function my_class ($value){$this->my_value[] = $value;}function set_value ($value){$this->$my_value= $value;}}$a = new my_class ('a');$a->my_value[] = 'b';$a->set_value ('c');$a->my_class('d');?>
The Singleton Pattern is handy whenever only one instance of a particular class can exist atany given time (and, yes, in case you’re wondering, you should expect the exam to test youon the basics of patterns, too).
In recent versions of PHP, the only difference between require() (or require_once()) andinclude() (or include_once()) is in the fact that, while the former will only throw a warningand allow the script to continue its execution if the include file is not found, the latter willthrow an error and halt the script. Therefore, Answer 5 is correct.