PHP Introduction


  1. Which of following variables can be assigned a value to it?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    A variable can’t start with a number. Also $this is a special variable that can’t be assigned, but $This can be assigned.


  1. Which of the following php statement/statements will store 120 in variable n?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    You need not specify the datatype in php.



  1. What will be the output of the following php code?
    <?php
    $n = 10;
    $n1 = 12;
    print $n . "+". $n1;
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    .(dot) is used to combine two parts of the statement. Example ( $n. “Hello World” ) will output 10Hello World.


  1. What will be the output of the following php code?
    <?php
    $n = "12";
    $n1 = "21";
    print $n+$n1;
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    The numbers inside the double quotes are considered as integers and not string, therefore the value 33 is printed and not 12+21.



  1. Which of the following PHP statements will output Hello interview Mania on the screen?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    echo(), print() and printf() all three can be used to output a statement onto the screen. The sprintf() statement is functionally identical to printf() except that the output is assigned to a string rather than rendered to the browser.