14 quizzes found.

What is the best way to iterate and modify every element of an array using PHP 5?

  1. You cannot modify an array during iteration
  2. for($i = 0; $i < count($array); $i++) { /* ... */ }
  3. foreach($array as $key => &$val) { /* ... */ }
  4. foreach($array as $key => $val) { /* ... */ }
  5. while(list($key, $val) = each($array)) { /* ... */}

Choose 1 answers

What combination of boolean values for $a, $b, $c, and $d will result in the variable $number being equal to 3?

<?php

$a = null;
$b = null;
$c = null;
$d = null;

if($a && !$b) {
  if(!!$c && !$d) {
    if($d && ($a || $c)) {
      if(!$d && $b) {
        $number = 1;
      } else {
        $number = 2;
      }
    } else {
      $number = 3;
    }
  } else {
    $number = 4;
  }
} else {
  $number = 5;
}
?>
  1. false, true, true, true
  2. true, false, true, false
  3. true, true, false, false
  4. false, true, true, false
  5. false, false, true, false

Choose 1 answers

The ____ operator is used to test if two values are identical in every way.

  1. !==
  2. instanceof
  3. =
  4. ==
  5. ===

Choose 1 answers

Which of the following comparisons will evaluate to true?

  1. 't' == t
  2. 1 === "1time"
  3. "top" == 0
  4. "top" === 0
  5. 1 == "1time"

Choose 3 answers

Identify the best approach to compare to variables in a binary-safe fashion

  1. Both strcmp() and $a === $b
  2. $a == $b
  3. $a === $b
  4. str_compare()
  5. strstr()

Choose 1 answers