Zend PHP 5.3 Certification Exam


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
  • Question 24/31

    Because PHP dynamically converts variables to different types as needed, you must be careful when performing string comparisons.

    What is the output of the following PHP script?

    
    <?php
        $str1 '57 channels';
        $str2 '1/2 a pack of cigarettes';
        $str3 '0x10';
    
        if ($str1 == 57) { echo 'a'; }
        else             { echo 'b'; }
    
        if ($str2 == 0.5)    { echo 'c'; }
        else if ($str2 == 1) { echo 'd'; }
        else                 { echo 'e'; }
    
        if ($str3 == 0)         { echo 'f'; }
        else if ($str3 == 16)   { echo 'g'; } // 0x10 is 16 in decimal
        else if ($str3 == 0x10) { echo 'h'; }
    ?>