PHP Functions


  1. What will be the output of the following PHP code ?
    <?php
    function Example($int)
    {
    if ($int == 10)
    echo "First Condition Executed...\n";
    if ($int == 20)
    echo "Second Condition Executed...";
    }
    Example(10);
    EXAMPLE(20);
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Function Is case Insensitive.


  1. What will be the output of the following PHP code ?
    <?php
    function fun($number)
    {
    $number = 5 + $number;
    echo $number;
    }
    fun(7);
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Simple arithmetic operation.



  1. What will be the output of the following PHP code ?
    <?php
    function Example($d)
    {
    $d = 12 + $d;
    echo "$d";
    }
    Example(6);
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    The function is defined as echo “$d”. This means $d is treated as a string and not as a variable.


  1. What will be the output of the following PHP code ?
    <?php
    function First($str)
    {
    echo "This is ". $Str;
    }
    First("Important");
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Variable Undeclared) $str is not the same as $Str.



  1. What will be the output of the following PHP code ?
    <?php
    function TvShow($int)
    {
    $TvShow = array("Naagin.", "CID.", "Big Boss.");
    echo "This is my favourite show ". $TvShow[$int];
    }
    TvShow(2);
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Simple use of arrays.