My Report

PHP Basic Online Test – 2


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. Which of the following PHP statements will output Hello World on the screen?

i) echo ("Hello World");
ii) print ("Hello World");
iii) printf ("Hello World");
iv) sprintf ("Hello World");

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

    <?php
    function track() {
    static $count = 0;
    $count++;
    echo $count;
    }
    track();
    track();
    track();
    ?>
    

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

    <?php
    $score = 1234;
    $scoreboard = (array) $score;
    echo $scoreboard[0];
    ?>
    

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

    <?php 
    $foo = 'Bob';              
    $bar = &$foo;              
    $bar = "My name is $bar";  
    echo $bar;
    echo $foo;
    ?>
        

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

    <?php
    $color = "maroon";
    $var = $color[2];
    echo "$var";
    ?>
    

6. Which of the below statements is equivalent to $add += $add?

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

    <?php
    $a = "clue";
    $a .= "get";
    echo "$a";
    ?>
    

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

    <?php
    $total = "25 students";
    $more = 10;
    $total = $total + $more;
    echo "$total";
    ?>
    

9. Which statement will output $x on the screen?

10. Which is the right way of declaring a variable in PHP?

i) $3hello
ii) $_hello
iii) $this
iv) $This

 

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.