PHP Practice Questions (Beginner Level)

🔹 1. Theory Questions

  1. What is PHP? Why is it called a server-side language?
  2. Who created PHP and in which year?
  3. What is the difference between client-side and server-side scripting?
  4. Name any 3 uses of PHP.
  5. What is XAMPP? Why do we use it?
  6. What is the role of Apache in XAMPP?
  7. Where should PHP files be stored in XAMPP?
  8. What is the latest version of PHP?
  9. Can the browser read PHP code directly? Why?
  10. What is the full form of PHP?

🔹 2. Output-Based Questions

👉 Predict the output:

Q1

<?php
echo "Hello PHP";
?>

Q2

<?php
$name = "Aditya";
echo $name;
?>

Q3

<?php
$a = 10;
$b = 20;
echo $a + $b;
?>

Q4

<?php
echo "10" + 5;
?>

Q5

<?php
echo "Hello" . " World";
?>

🔹 3. Error Finding Questions

👉 Find and fix errors:

Q1

<?php
echo Hello World;
?>

Q2

<?php
$name = Aditya;
echo $name;
?>

Q3

<?php
echo "Welcome"
?>

Q4

<?php
$1name = "PHP";
echo $1name;
?>

🔹 4. Practical Coding Questions

👉 Write programs:

Q1

Print your name using PHP


Q2

Create variables for:

  • Name
  • Age
    Print:
    👉 My name is ___ and I am ___ years old

Q3

Add two numbers and print result


Q4

Print this output:

Welcome to PHP Programming

Q5

Create a PHP file and run it on localhost


🔹 5. Challenge Questions 🚀

Q1

Print:

Hello
World

(Use single echo)


Q2

Create variables:

$a = 5;
$b = 3;

Print:

Sum = 8

Q3

Mix HTML + PHP:

<h1>Welcome Message</h1>

Use PHP to print your name below it


🎯 Bonus Teaching Tip

👉 Ask students to:

  • Install XAMPP
  • Create 3 PHP files
  • Run them in browser