PHP Syntax


  1. What will be the output of the following PHP code ?
    <?php
    $Country1 = "INDIA";
    $Country2 = "1";
    $Country3 = "USA";
    echo "$Country1" + "$Country2" . "$Country3";
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    + gives the value 1 and . is used to give join 1 and USA.


  1. What will be the output of the following PHP code ?
    /*
    echo "Hello Interview Mania";
    */
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    /* */ is used for commenting multiple lines.



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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Use of undefined constant India.


  1. What will be the output of the following PHP code ?
    <?php
    $Name = "Rahul";
    $Name = "Ajit";
    echo "$Name";
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    The variable contains the last value which has been assigned.



  1. What will be the output of the following PHP code ?
    <?php
    $name1= Ajit;
    $name2= Rahul;
    echo "$name1"."$name2";
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    It has to be $name1= “Ajit”; and $name2= “Rahul”; therefore the error.