214 quizzes found.

Consider the following script. Each ? in the above script represents an integer index against the $s array. In order to display the Hello, World! string when executed, what must the missing integer indexes be?

<?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[?]});?>
  1. Group A: 4,3,0,4,9,9 Group B: 7,8
  2. Group A: 1,3,0,4,9,9 Group B: 7,6
  3. Group A: 1,3,2,3,0,4 Group B: 5,8
  4. Group A: 0,4,9,9,9,9 Group B: 7,8
  5. Group A: 4,3,0,4,9,9 Group B: 7,8

Choose 1 answers

Run-time inclusion of a PHP script is performed using the ________ construct, while compile-time inclusion of PHP scripts is performed using the _______ construct

  1. include_once, include
  2. require, include
  3. require_once, include
  4. include, require
  5. All of the above are correct

Choose 1 answers

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.

Which of the following expressions multiply the value of the integer variable $a by 4?

  1. $a *= pow (2, 2);
  2. $a >>= 2;
  3. $a <<= 2;
  4. $a += $a + $a;
  5. None of the above

Choose 2 answers

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.

At the end of the execution of the following script, which values will be stored in the $a->my_value array?

<?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');?>
  1. c
  2. b
  3. a
  4. d
  5. e

Choose 3 answers

Which object-oriented pattern would you use to implement a class that must be instantiated only once for the entire lifespan of a script?

  1. Model-view-controller
  2. Abstract factory
  3. Singleton
  4. Proxy
  5. State

Choose 1 answers

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).