My Report

PHP Basic Online Test – 3


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 value of $a and $b after the function call in the following PHP code?

    <?php
    function doSomething( &$arg ) {
        $return = $arg;
        $arg += 1;
        return $return;	
    }
    $a = 3;
    $b = doSomething( $a );
    ?>
        

2. 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]); 
    }
    ?> 
    

3. Who is the father of PHP?

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

    <?php
    $team = "arsenal";
    switch ($team) {
    case "manu":
        echo "I love man u";
    case "arsenal":
        echo "I love arsenal";
    case "manc":
        echo "I love manc"; }
    ?>
    

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

    <?php
    $a = 5;
    $b = 5;
    echo ($a === $b);
    ?>
    

6. If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?

7. Which of the below symbols is a newline character?

8. Which of the conditional statements is/are supported by PHP?

i) if statements
ii) if-else statements
iii) if-elseif statements
iv) switch statements

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

    <?php
    $num = 10;
    echo 'What is her age? \n She is $num years old';
    ?>  
        

10. Which of the looping statements is/are supported by PHP?

i) for loop
ii) while loop
iii) do-while loop
iv) foreach loop

 

Start practicing “1000 MCQs on PHP”, and once you are ready, you can take tests on all topics by attempting our “PHP Test Series”.

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.