📝 Advanced PHP Exam Paper (Tough Level)
Subject: Advanced PHP Programming
Time: 3 Hours
Maximum Marks: 100
📘 Section A – Advanced MCQs (10 × 2 = 20 Marks)
- What will be the output?
$a = "10abc";
$b = 5;
echo $a + $b;
A) 15
B) 105
C) Error
D) 10abc5
✅ Answer: A
- Which function prevents SQL Injection?
A) mysqli_query()
B) htmlspecialchars()
C) prepare() (PDO)
D) echo()
✅ Answer: C
- What is the output?
var_dump([] == false);
A) true
B) false
C) error
D) null
✅ Answer: A
- Which is fastest output method?
A) print
B) echo
C) printf
D) var_dump
✅ Answer: B
- What is the scope of a static variable inside function?
A) Global
B) Local but retains value
C) Block only
D) Session
✅ Answer: B
- What does
finallyguarantee?
A) Runs only if no error
B) Runs always
C) Runs on fatal error only
D) Skips execution
✅ Answer: B
- Output?
echo "5" . 2 + 3;
A) 523
B) 10
C) 55
D) Error
✅ Answer: B
- Which handles fatal errors indirectly?
A) try-catch
B) set_error_handler()
C) register_shutdown_function()
D) error_reporting()
✅ Answer: C
- Which superglobal is immutable?
A) $_POST
B) $_GET
C) $_SERVER
D) None
✅ Answer: D
- What does
strict_types=1do?
A) Converts types automatically
B) Enforces strict type checking
C) Disables errors
D) Improves speed
✅ Answer: B
📗 Section B – Analytical Questions (5 × 4 = 20 Marks)
- Explain the difference between mysqli and PDO with real-world usage.
- Analyze:
if ("0" == false) echo "Yes";
Why does this happen?
- Explain how PHP handles type juggling with examples.
- What are closures in PHP? Give a real use case.
- Explain error vs exception vs throwable with hierarchy.
📙 Section C – Long Programming Questions (4 × 10 = 40 Marks)
✅ Q1. Build a secure login system with:
- Password hashing
- Session handling
- Input validation
✅ Q2. Create a REST API in PHP:
- Return JSON
- Handle GET request
- Include error handling
✅ Q3. Write a PHP script to:
- Upload file
- Validate type & size
- Handle errors
✅ Q4. Create a custom error handling system:
- Convert errors to exceptions
- Log errors to file
- Show user-friendly message
💻 Section D – Case Study (1 × 20 = 20 Marks)
🔥 Scenario:
Your PHP website is:
- Showing white screen
- Users report slow performance
- Database queries sometimes fail
Questions:
- How will you debug the white screen issue?
- How will you optimize performance?
- How will you handle database failures?
- Suggest a complete error-handling strategy.
🏆 Bonus (Optional – 10 Marks)
Build a mini MVC structure in PHP:
- Routing
- Controller
- View
- Error handling
🎯 Examiner Expectations (High-Level)
- Clean architecture (MVC mindset)
- Secure coding (XSS, SQL Injection)
- Proper error handling
- Use of modern PHP (PDO, exceptions)
- Real-world thinking
🔥 Difficulty Level
| Section | Level |
|---|---|
| MCQ | Medium |
| Analytical | Hard |
| Coding | Very Hard |
| Case Study | Expert |






