My Report

PHP Programming Mock Test 10


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement
 10%

Question 1 of 10

1. What will be the output of the following PHP code?

<?php
function test($int)
{
    if ($int == 1)
        echo "This Works";
    if ($int == 2)
        echo "This Too Seems To Work";
}
test(1);
TEST(2);
?>

Question 1 of 10

Question 2 of 10

2. What will be the output of the following PHP code?

<?php 
$x = 75;
$y = 25; 
function addition()
{
    $GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y'];
}
addition();
echo $z;
?>

Question 2 of 10

Question 3 of 10

3. What will be the output of the following PHP code?

<?php
function addFive($num)
{
    $num += 5;
}
function addSix(&$num)
{
    $num += 6;
}
$orignum = 10;
addFive( &$orignum );
echo "Original Value is $orignum<br />";
addSix( $orignum );
echo "Original Value is $orignum<br />";
?>

Question 3 of 10

Question 4 of 10

4. What will be the output of the following PHP code?

<?php
function 2myfunc()
{
    echo "Hello World";
}
2myfunc();
?>

Question 4 of 10

Question 5 of 10

5. What will be the output of the following PHP code?

<?php
function sayHello()
{
   echo "HelloWorld<br />";
}
$function_holder = "sayHello";
$function_holder();
?>

Question 5 of 10

Question 6 of 10

6. What will be the output of the following PHP code?

    <?php
        echo ord ("hi");
    ?>

Question 6 of 10

Question 7 of 10

7. What will be the output of the following PHP code?

<?php
function time($string)
{
    echo strtr("Towe Pa55", "ow5", $string);
}
time("ims");
?>

Question 7 of 10

Question 8 of 10

8. What will be the output of the following PHP code?

<?php
    function multi($num)
    {
        if ($num == 3)
            echo "I Wonder";
        if ($num == 7)
            echo "Which One";
        if ($num == 8)
            echo "Is The";
        if ($num == 19)
            echo "Correct Answer";
    }
    $can = stripos("I love php, I love php too!","PHP");
    multi($can);
?>

Question 8 of 10

Question 9 of 10

9. What will be the output of the following PHP code?

<?php
function constant()
{
    define("GREETING", "Welcome to Narnia");
    echo greeting;
}
?>

Question 9 of 10

Question 10 of 10

10. What will be the output of the following PHP code?

    
<?php
    $str = "Hello world. It's a beautiful day.";
    print_r (explode(" ",$str));
?>

Question 10 of 10


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.