Skip to main content

PHP Interview Cheat Sheet

Top 50 interview questions with concise answers. Print this page or save as PDF for offline study.

View All PHP Questions

1. What is PHP and where is it commonly used?

2. What does server-side scripting mean in PHP?

3. What is the difference between echo and print?

4. What are PHP variables and how are they declared?

5. What are PHP data types?

6. What is an associative array in PHP?

7. What is the difference between == and === in PHP?

8. What are PHP superglobal variables?

9. What is the role of $_GET and $_POST?

10. What is a session in PHP?

11. What is a cookie in PHP?

12. What is the include statement used for?

13. What is the difference between include and require?

14. What is form handling in PHP?

15. What is the purpose of htmlspecialchars()?

16. What is PDO in PHP?

17. What is SQL injection and how do you prevent it in PHP?

18. What is the use of isset() in PHP?

19. What is empty() in PHP?

20. How does PHP handle errors?

21. What is the purpose of php.ini?

22. What is file handling in PHP?

23. What is the difference between single and double quotes in PHP?

24. What is the purpose of the header() function?

25. What is JSON encoding and decoding in PHP?

26. What is the difference between GET and POST methods in PHP?

27. What is PHP’s type juggling and how does it affect comparisons?

28. What is the purpose of filter_var() in PHP?

29. What are magic constants in PHP?

30. What are magic methods in PHP?

31. What is the difference between include_once and require_once?

32. What is the purpose of session_start()?

33. What is output buffering in PHP?

34. What are PHP traits?

35. What is the difference between public, private, and protected?

36. How does PHP handle exceptions?

37. What is the purpose of namespaces in PHP?

38. What is autoloading in PHP?

39. What is Composer in PHP?

40. What is the difference between == and === when comparing arrays?

41. What is the purpose of htmlentities()?

42. How do you connect PHP with MySQL using PDO?

43. What is the difference between mysqli and PDO?

44. What is a callback function in PHP?

45. What is the purpose of phpinfo()?

46. What is the difference between require, include, require_once, and include_once in real project scenarios?

47. What is the role of PHP’s garbage collection mechanism?

48. What is the difference between session storage and token-based authentication?

49. How does PHP handle file uploads and what security concerns exist?

50. What is output escaping and why is it important in PHP apps?

Ready to level up? Start Practice