1. Question: Which of the following are valid PHP variables?

    A
    @$foo

    B

    C

    D
    $variable

    E
    $0x0

    Note: Not available
    1. Report
  2. Question: What is the best way to iterate and modify every element of an array using PHP 5?

    A
    You cannot modify an array during iteration

    B
    for($i = 0; $i < count($array); $i++) { /* ... */ }

    C
    foreach($array as $key => &$val) { /* ... */ }

    D
    foreach($array as $key => $val) { /* ... */ }

    E
    while(list($key, $val) = each($array)) { /* ... */

    Note: Not available
    1. Report
  3. Question: What is the output of the following PHP code? <?php define('FOO', 10); $array = array(10 => FOO, "FOO" => 20); print $array[$array[FOO]] * $array["FOO"]; ?>

    A
    FOO

    B
    100

    C
    200

    D
    20

    E
    10

    Note: Not available
    1. Report
  4. Question: What is the output of the following PHP script? <?php $a = 1; $b = 2.5; $c = 0xFF; $d = $b + $c; $e = $d * $b; $f = ($d + $e) % $a; print ($f + $e); ?>

    A
    643.75

    B
    432

    C
    643

    D
    257

    E
    432.75

    Note: Not available
    1. Report
  5. Question: 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; } ?>

    A
    false, true, true, true

    B
    true, false, true, false

    C
    true, true, false, false<

    D
    false, true, true, false

    E
    false, false, true, false

    Note: Not available
    1. Report
  6. Question: <?php $string = "111221"; for($i = 0; $i < strlen($string); $i++) { $current = $string[$i]; $count = 1; while(isset($string[$i + $count]) && ($string[$i + $count] == $current)) $count++; $newstring .= "$count{$current}"; $i += $count-1; } print $newstring; ?>

    A
    312211

    B
    3312212

    C
    11221221

    D
    221131

    E
    3211122

    Note: Not available
    1. Report
  7. Question: What is the best way to ensure that a user-defined function is always passed an object as its single parameter?

    A
    function myfunction(stdClass $a)

    B
    function myfunciton($a = stdClass)

    C
    Use is_object() within the function

    D
    There is no way to ensure the parameter will be an object

    E
    <label for="10_5">function myfunction(Object $a)</label>

    Note: Not available
    1. Report
  8. Question: What does the following function do, when passed two integer values for $p and $q?
    <?php
    function magic($p, $q) {
      return ($q == 0)?$p:magic($q, $p % $q);
    }
    ?>

    A
    Loops infinitely

    B
    Switches the values of $p and $q

    C
    Determines if they are both even or odd

    D
    Determines the greatest common divisor between them

    E
    Calculates the modulus between the two

    Note: Not available
    1. Report
  9. Question: ______ operator is used to test if two values are identical in every way.

    A

    B

    C
    =

    D

    E

    Note: Not available
    1. Report
  10. Question: What would go in place of ?????? below to make this script execute without a fatal error? <?php $a = 1; $b = 0; ?????? $c = $a / $b; ?>

    A
    quit();

    B
    die();

    C
    stop();

    D
    __halt_compiler();

    E
    exit();

    Note: Not available
    1. Report
Copyright © 2025. Powered by Intellect Software Ltd