My Report

PHP Programming Practice 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

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

  <?php
      echo(atan(0.50));
  ?>

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

<?php
function addFunction($num1, $num2)
{
    $sum = $num1 + $num2;
    return $sum;
}
$return_value = addFunction(10, 20);
echo "Returned value from the function : " .$return_value
?>

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

<?php
$a = array("hi", "hello", "bye");
for (;count($a) < 5;) 
{
    if (count($a) == 3)
	    print $a;         
}
?>

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

<?php
$a = array("hi", "hello", "bye");
foreach ($a as $value) 
{
    if (count($a) == 2)
	    print $value;         
}
?>

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

 
<?php
    function sum($num1, $num2)
    {
        $total = $num1 + $num2;
        echo "chr($total)"; 
    }
    $var1 = "sum";
    $var1(5, 44);    
?>

6. 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.");
?>

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

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

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);
?>

9. 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);
?>

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

<?php
$user = array("Ashley", "Bale", "Shrek", "Blank");
for ($x = 0; $x < count($user); $x++) 
{
    if ($user[$x] == "Shrek") 
	    continue;
    printf ($user[$x]); 
}
?>

 

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.