PHP Functions


  1. What will be the output of the following PHP code?
    <?php
    echo(atan(0.60));
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    The atan() function returns the arc tangent of arg as a numeric value between -Pi/2 and Pi/2 radians.


  1. What will be the output of the following PHP code?
    <?php
    echo ord ("Rahul");
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    The ord() function returns the ASCII value of the first character of a string. The ASCII value of R is 82, thus 82 was displayed.



  1. What will be the output of the following PHP code?
    <?php
    echo chr(51);
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    The chr() function returns a character from the specified ASCII value. Since the ASCII value of 3 is 51, thus 3 was displayed.


  1. What will be the output of the following PHP code?
    <?php
    function fun($message)
    {
    echo "$message";
    }
    $var = "fun";
    $var("Executed...");
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    It is possible to call a function using a variable which stores the function name.



  1. What will be the output of the following PHP code?
    <?php
    $option2 = "Hey";
    function fun($option1)
    {
    echo $option1;
    echo $option2;
    }
    fun("Welcome");
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    If you want to put some variables in function that was not passed by it, you must use “global”. Inside the function type global $option2.