PHP Variables


  1. What will be the output of the following PHP code ?
    <?php
    $Fiv-e = 5;
    $Si-x = 6;
    $Seve-n = 7;
    $Eigh-t = 8;
    echo "$Fiv-e / $Si-x + $Seve-n / $Eigh-t";
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    You can't use - in a variable name.


  1. What will be the output of the following PHP code ?
    <?php
    $9nine = 9;
    $8eight = 8;
    $6six = 6;
    echo $9nine + $8eight / $6six - 3;
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    A variable name can not start with a numeric value.



  1. What will be the output of the following PHP code ?
    <?php
    var $five = 5;
    var $six = 6;
    echo $five / $six * $five / $six * $six;
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    You can not use var before a variable name.


  1. What will be the output of the following PHP code ?
    <?php
    int $five = 5;
    echo "$five";
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Unlike other programming languages there are no data types in PHP.



  1. What will be the output of the following PHP code ?
    <?php
    $r = 8;
    $s = -6;
    $t = 22;
    echo 8 + $s * $t / $r;
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    First the * is evaluated then / followed by + therefore we can rewrite this expression as 8 +((- 6 * 22) / 8) which results in -8.5.