PHP MCQ Quiz Hub

PHP MCQ– Basics

Choose a topic to test your knowledge and improve your PHP skills

What does PHP stand for? i) Personal Home Page ii) Hypertext Preprocessor iii) Pretext Hypertext Processor iv) Preprocessor Home Page





✅ Correct Answer: 4

PHP files have a default file extension of_______





✅ Correct Answer: 3

What should be the correct syntax to write a PHP code?





✅ Correct Answer: 3

Which of the following is/are a PHP code editor?





✅ Correct Answer: 2

Which of the following must be installed on your computer so as to run PHP script? i) Adobe Dreamweaver ii) XAMPP iii) Apache and PHP iv) IIS





✅ Correct Answer: 4

Which version of PHP introduced Try/catch Exception?





✅ Correct Answer: 4

How should we add a single line comment in our PHP code? i) /? ii) // iii) # iv) /* */





✅ Correct Answer: 3

Which of the following PHP statement/statements will store 111 in variable num? i) int $num = 111; ii) int mum = 111; iii) $num = 111; iv) 111 = $num;





✅ Correct Answer: 3

What will be the output of the following PHP code? <?php $num = 1; $num1 = 2; print $num . "+". $num1; ?>





✅ Correct Answer: 2

Which is the right way of declaring a variable in PHP? i) $3hello ii) $_hello iii) $this iv) $This





✅ Correct Answer: 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; ?>





✅ Correct Answer: 3

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





✅ Correct Answer: 2

What will be the output of the following PHP code? <?php $color = "maroon"; $var = $color[2]; echo "$var"; ?>





✅ Correct Answer: 4

What will be the output of the following PHP code? <?php $score = 1234; $scoreboard = (array) $score; echo $scoreboard[0]; ?>





✅ Correct Answer: 3

What will be the output of the following PHP code? <?php $total = "25 students"; $more = 10; $total = $total + $more; echo "$total"; ?>





✅ Correct Answer: 3

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





✅ Correct Answer: 2

Which statement will output $x on the screen?





✅ Correct Answer: 1

Which statement will output $x on the screen?





✅ Correct Answer: 1

What will be the output of the following PHP code? <?php function track() { static $count = 0; $count++; echo $count; } track(); track(); track(); ?>





✅ Correct Answer: 1

What will be the output of the following PHP code? <?php $a = "clue"; $a .= "get"; echo "$a"; ?>





✅ Correct Answer: 4

What will be the output of the following PHP code? <?php $a = 5; $b = 5; echo ($a === $b); ?>





✅ Correct Answer: 3

Which of the below symbols is a newline character?





✅ Correct Answer: 2

Which of the conditional statements is/are supported by PHP? i) if statements ii) if-else statements iii) if-elseif statements iv) switch statements





✅ Correct Answer: 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"; } ?>





✅ Correct Answer: 3

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





✅ Correct Answer: 2

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





✅ Correct Answer: 4

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





✅ Correct Answer: 2

Who is the father of PHP?





✅ Correct Answer: 1