Learn with Yasir
Share Your Feedback

PHP Basics MCQs – Multiple Choice Questions for Beginners and Interviews


Sharpen your PHP skills with these multiple choice questions on PHP basics. Great for beginners, students, and interview preparation. Start practicing now!.

📝 Multiple Choice Questions

🟢 Beginner

Q1. What is the output of the following PHP code?

<?php
    echo "Hello ";
    echo "World!";
?>
  1. Hello World!
  2. Hello World
  3. World Hello
  4. Error
Answer

Hello World!

The `echo` statement is used to output the text. In this case, "Hello" and "World!" are printed sequentially without any issues.


🟡 Intermediate

Q1. What is the output of the following PHP code?

<?php
    $x = 5;
    $y = 10;
    echo $x + $y;
?>
  1. 15
  2. 510
  3. 5 + 10
  4. Error
Answer

15

The `+` operator is used to add two numbers. In this case, the sum of `$x` and `$y` (5 + 10) results in 15.


Q2. What is the output of the following PHP code?

<?php
    $a = 10;
    $b = 5;
    $a = $a / $b;
    echo $a;
?>
  1. 2
  2. 5
  3. 10
Answer


🔴 Advanced


🧠 Practice & Progress

Explore More Topics

PHP Basics

More ...