43 PHP interview questions with answers
43 PHP interview questions with detailed answers, sorted from basic to advanced. Free to practice, with progress saved automatically.
All PHP interview questions
What is PHP and what does it stand for?
What are PHP superglobals? Give examples.
What's the difference between $_GET and $_POST?
What are PHP data types and what are the main ones?
What is the difference between == and === operators?
How do you work with arrays in PHP? What are the main types?
What are common string functions in PHP?
What is the difference between include and require?
How do you handle form data in PHP?
What are PHP error types and how are they handled?
How do you define and use constants in PHP?
What are classes and objects in PHP? What's the difference?
What is inheritance in PHP?
Does PHP support multiple inheritance? How do you achieve similar functionality?
What are interfaces and when should you use them?
What are Traits in PHP and how do they solve problems?
What are magic methods in PHP? Give examples.
What is the difference between static and instance methods?
What are access modifiers (public, private, protected)?
What is PDO and how does it prevent SQL injection?
How do PHP sessions work and what's the difference from cookies?
What are namespaces and why should you use them?
What is autoloading and how do you implement it?
What are generators in PHP and when do you use them?
What is the difference between unset() and unlink()?
How do you prevent Cross-Site Scripting (XSS) attacks in PHP?
How do you handle exceptions in PHP?
What is type hinting and why is it important?
What are abstract classes and when do you use them?
What are typed class constants in PHP 8.3 and why are they useful?
What are Fibers in PHP 8.1 and how are they different from threads?
What are the constraints of readonly classes introduced in PHP 8.2?
What are Enums in PHP 8.1 and when should you use them instead of constants?
What are Value Objects in PHP and when should you use them instead of primitives?
Why store passwords with `password_hash()` / `password_verify()` instead of `md5`/`sha1`?
What is a nullable type (`?type`) in PHP?
What are streams and stream wrappers in PHP?
What is OPcache and how does it optimize PHP performance?
What principles make up SOLID (applied in PHP)?
What is Composer and how does Laravel use it?
How does PHP 8's `match` differ from `switch`?
What problems do PHP 8 named arguments and constructor property promotion solve?
What are PHP 8 attributes? How do they differ from docblock annotations, and how do frameworks use them?