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 sum($x, $y)
{
    $z = $x + $y;
    return $z;
}
echo "5 + 10 = " . sum(7,13) . "<br>";
echo "7 + 13 = " . sum(2,4) . "<br>";
echo "2 + 4 = " . sum(5,10);
?>

Question 1 of 10

Question 2 of 10

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

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

Question 2 of 10

Question 3 of 10

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

    <?php
        function foo($msg)
        {
            echo "$msg";
        }
        $var1 = "foo";
        $var1("will this work");
    ?>

Question 3 of 10

Question 4 of 10

4. 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 4 of 10

Question 5 of 10

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

<?php
    echo str_pad("Salad", 5)." is good.";
?>

Question 5 of 10

Question 6 of 10

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

<?php
function one($string)
{
    echo "I am ". $String;
}
one("Batman");
?>

Question 6 of 10

Question 7 of 10

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

<?php
    function calc($num1, $num2)
    {
        $total = $num1 * $num2; 
    }
    $result = calc(42, 0);
    echo $result;    
?>

Question 7 of 10

Question 8 of 10

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

<?php
function movie($int)
{
    $movies = array("Fight Club", "Kill Bill", "Pulp Fiction");
    echo "You Do Not Talk About ". $movie[$integer];
}
movie(0);
?>

Question 8 of 10

Question 9 of 10

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

<?php
for ($i = 0; $i < 5; $i++) 
{
    for ($j = $i; $j > 0; $i--)
        print $i;
}
?>

Question 9 of 10

Question 10 of 10

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

<?php
function do($myString)
{
    echo strpos($myString, "donkey",0);
}
do("The donkey looks like a horse.");
?>

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.