👇
📝 Full PHP Exam Paper
Subject: PHP Programming
Time: 3 Hours
Maximum Marks: 100
📘 Section A – Objective (MCQs)
(10 × 1 = 10 Marks)
- PHP stands for:
A) Personal Home Page
B) Hypertext Preprocessor
C) Private Home Page
D) Preprocessor Home Page
✅ Answer: B - Which symbol is used for variables in PHP?
A) #
B) $
C) @
D) &
✅ Answer: B - Which function outputs text?
A) print()
B) echo()
C) Both
D) None
✅ Answer: C - Which error stops execution?
A) Warning
B) Notice
C) Fatal Error
D) Info
✅ Answer: C - Which superglobal is used for form data?
A) $_FORM
B) $_POST
C) $_DATA
D) $_INPUT
✅ Answer: B - Which function connects to MySQL (procedural)?
A) connect_db()
B) mysqli_connect()
C) db_connect()
D) mysql_link()
✅ Answer: B - What does
isset()check?
A) Empty value
B) Variable exists
C) Data type
D) Output
✅ Answer: B - Which keyword is used for exception?
A) catch
B) throw
C) try
D) All
✅ Answer: D - Which function is used for sessions?
A) session_create()
B) session_start()
C) session_open()
D) start_session()
✅ Answer: B - Default file extension of PHP?
A) .html
B) .js
C) .php
D) .xml
✅ Answer: C
📗 Section B – Short Answer
(10 × 2 = 20 Marks)
- What is PHP?
- Difference between GET and POST
- What is a session?
- What is a cookie?
- Define array in PHP
- What is error handling?
- What is
includevsrequire? - What is a function?
- What is
$_SERVER? - What is PDO?
📙 Section C – Long Answer
(5 × 6 = 30 Marks)
- Explain PHP data types with examples
- Explain loops in PHP (for, while, foreach)
- Explain form handling with example
- Explain error handling in PHP
- Explain session and cookie with examples
💻 Section D – Practical / Coding
(4 × 10 = 40 Marks)
✅ Q1. Write a PHP program to check even or odd number.
<?php
$num = 10;if ($num % 2 == 0) {
echo "Even Number";
} else {
echo "Odd Number";
}
?>
✅ Q2. Create a form and display submitted data.
<form method="post">
Name: <input type="text" name="name">
<input type="submit">
</form><?php
if ($_POST) {
echo "Name: " . $_POST['name'];
}
?>
✅ Q3. Connect to MySQL database.
<?php
$conn = mysqli_connect("localhost", "root", "", "test");if (!$conn) {
die("Connection failed");
}
echo "Connected successfully";
?>
✅ Q4. Exception Handling Example
<?php
try {
if (!file_exists("test.txt")) {
throw new Exception("File not found");
}
} catch (Exception $e) {
echo $e->getMessage();
}
?>
🏆 Bonus Question (Optional – 10 Marks)
Create a login system using:
- Form
- Session
- Validation
📊 Marking Scheme
| Section | Marks |
|---|---|
| A | 10 |
| B | 20 |
| C | 30 |
| D | 40 |
| Bonus | 10 |
🎯 Examiner Tips
- Write clean syntax
- Use comments in code
- Handle errors properly
- Show output clearly
- Follow best practices






