PHP MCQs with answers Page - 5

Dear candidates you will find MCQ questions of PHP here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question

Y

Yogesh • 7.43K Points
Tutor III

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

Code:
<?php
    function uppercase($string)
    {
        echo ucwords($string);
    }
    $wow = "uppercase";
    $wow("Time to live king size");
?> 
  • (A) Time To Live King Size
  • (B) Uppercase
  • (C) Time to live king size
  • (D) TIME TO LIVE KING SIZE

Y

Yogesh • 7.43K Points
Tutor III

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

Code:
<?php
    function calc($num1, $num2)
    {
        $total = $num1 * $num2; 
    }
    $result = calc(42, 0);
    echo $result;    
?>
  • (A) 84
  • (B) 0
  • (C) Error
  • (D) 42

Y

Yogesh • 7.43K Points
Tutor III

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

Code:
<?php
function constant()
{
    define("GREETING", "Welcome to Narnia",true);
    echo greeting;
}
?>
  • (A) ERROR
  • (B) GREETING
  • (C) Welcome to Narnia
  • (D) greeting

Y

Yogesh • 7.43K Points
Tutor III

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

Code:
<?php
    echo str_pad("Salad", 5)." is good.";
?>
  • (A) Salad is good
  • (B) is good Salad
  • (C) SaladSaladSaladSaladSalad is good
  • (D) is good SaladSaladSaladSaladSalad

Y

Yogesh • 7.43K Points
Tutor III

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

Code:
<?php
function colour()
{ 
    $colors = array("red", "green", "blue", "yellow"); 
    foreach ($colors as $value)
    {
        echo "$value <br>";
    }
}
colour();
?> 
  • (A) red green yellow blue
  • (B) green blue yellow red
  • (C) red green blue yellow
  • (D) red blue yellow green

Y

Yogesh • 7.43K Points
Tutor III

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

Code:
<?php
function 2myfunc()
{
    echo "Hello World";
}
2myfunc();
?>
  • (A) ERROR
  • (B) No Output
  • (C) Hello World
  • (D) None of the mentioned

Y

Yogesh • 7.43K Points
Tutor III

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

Code:
<?php
        function foo($msg)
        {
            echo "$msg";
        }
        $var1 = "foo";
        $var1("will this work");
    ?>
  • (A) error
  • (B) $msg
  • (C) 0
  • (D) will this work

Y

Yogesh • 7.43K Points
Tutor III

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

Code:
<?php
$user = array("Ashley", "Bale", "Shrek", "Blank");
    for ($x=0; $x < count($user) - 1; $x++)	
    {
        if ($user[$x++] == "Shrek") 
		    continue;
        printf ($user[$x]); 
    }
?>
  • (A) Bale
  • (B) AshleyShrek
  • (C) BaleBlank
  • (D) AshleyBaleBlank

Y

Yogesh • 7.43K Points
Tutor III

Q. Within a namespace, for accessing the built-in PHP classes you can prefix the class name with a . . . . . and let PHP look in the global class list. 

  • (A) percent
  • (B) ampersand
  • (C) asterix
  • (D) backslash

Y

Yogesh • 7.43K Points
Tutor III

Q. Which of the below namespace declaration is correct?

  • (A) namespace ORA:
  • (B) namespace 1_RA;
  • (C) namespace ORA;
  • (D) namespace ORA_#;

Be the first to start discuss.

Download our easy to use, user friendly Android App from Play Store. And learn MCQs with one click.

Image

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.