PHP Interview Questions

Looking for PHP interview questions?

The world of programming and web development has evolved a lot. Despite the increased popularity of Python, Java, Ruby, and other languages, PHP remains an important software in the tech stack because it was solely made for web development. For instance, you don’t need a major compilation step to write PHP code. You can write your scripts, upload them on the server and access them with ease – this helps you experiment more and provides you quick bug fixes. However, we will recommend you learn other languages as well along with PHP, as companies today require candidates with a wider repository of tech skills. Nevertheless, being aware about PHP is certainly a plus when you apply for interviews. So here are 100 PHP interview questions you should prepare for:

Q1. What is PHP and what does it stand for?

Q2. Which programming language is the most similar to PHP?

Q3. What’s the full form of PEAR?

Q4. Which version of PHP is used?

Q5. What do you do to execute a PHP script from a command line?

Q6. What’s the name of the scripting engine in PHP?

Q7. Tell the difference between PHP4 and PHP5.

Q8. What are some common content management systems used in PHP?

Q9. Is PHP case sensitive?

Q10. Explain some characteristics of PHP variables?

Q11. What do you mean by ‘escaping to PHP’?

Q12. What are the rules of naming a PHP variable?

Q13. What is NULL?

Q14. What’s the process of defining a constant in PHP?

Q15. How do PHP constants and variables differ?

Q16. What’s the use of break and continue statements?

Q17. What are the most common ways to start and finish a PHO block code?

Q18. What does a final class and a final method mean?

Q19. How do you compare objects in PHP?

Q20. Can PHP and Javascript, and PHP and HTML interact? If yes, then how?

Q21. What are some of the most popular frameworks in PHP?

Q22. What are the different data types in PHP?

Q23. What are constructor and destructor in PHP?

Q24. Explain include() and require() functions.

Q25. How does require() differ from require_once()?

Q26. What are various kinds of errors in PHP?

Q27. Explain the syntax for ‘foreach’ loop with example.

Q28. Explain the three types of Array in PHP.

Q29. How does a single quoted string differ from a double quoted string?

Q30. How do you concatenate two strings in PHP?

Q31. Can you set an infinite execution time for PHP script?

Q32. Explain the difference between difference between “echo” and “print” in PHP.

Q33. What are the different functions in PHP?

Q34. Explain the difference between asp net and PHP.

Q35. How are sessions and cookies used in PHP?

Q36. Discuss overloading and overriding in PHP.

Q37. How does $message differ from $$message in PHP?

Q38. How do you create a database using PHP and MySQL?

Q39. Explain the GET and POST methods in PHP. What’s the difference between them?

Q40. Why is a callback used in PHP?

Q41. What is a lambda function in PHP?

Q42. What are PHP Magic Methods/Functions?

Q43. What’s the process to encrypt password using PHP?

Q44. How do you connect a URL in PHP?

Q45. Explain Type hinting in PHP.

Q46. How does runtime exception differ from compile time exception?

Q47. Is multiple inheritance supported in PHP?

Q48. How is the comparison of objects done in PHP?

Q49. What do you need to be able to use image function?

Q50. What type of operation is needed when passing values through a form or an URL?

Q51. Discuss the use of the function ‘imagetypes()’.

Q52. Discuss what functions can be used to get an image’s properties (size, width, and height)?

Q53. What are some features of PHP7?

Q54. How is it possible to set an infinite execution time for PHP script?

Q55. What’s the meaning of PHP error ‘Parse error in PHP – unexpected T_variable at line x’?

Q56. What’s the use of the function file_get_contents()?

Q57. How do you connect to a MySQL database from a PHP script?

Q58. How do you handle the result set of MySQL in PHP?

Q59. How can you know the number of rows returned in the result set?

Q60. Which function gives us the number of affected entries by a query?

Q61. Explain the difference between mysqli_fetch_object() and mysqli_fetch_array().

Q62. How do you access the data sent through the URL with the GET method?    

Q63. How do you access the data sent through the URL with the POST method?

Q64. How do you check the value of a given variable is a number?

Q65. How do you check the value of a given variable is alphanumeric?

Q66. What does the unlink() function mean?

Q67. What does the unset() function mean?

Q68. Can you remove the HTML tags from data?

Q69. What is the most convenient hashing method for using hash passwords?

Q70. Which cryptographic extension provides generation and verification of digital signatures?

Q71. Will a comparison of an integer 12 and a string “13” work in PHP?

Q72. Can you cast types in PHP?

Q73. When does a conditional statement end with endif?

Q74. How do you use the ternary conditional operator in PHP?

Q75. If the variable $var1 is set to 10 and the $var2 is set to the character var1, what’s the value of $$var2?

Q76. What do you mean by accessing a class via ::?

Q77. Are Parent constructors called implicitly inside a class constructor?

Q78. Tell the difference between __sleep and __wakeup.

Q79. What is a session in PHP? How do you initiate it?

Q80. What do you understand by a Persistent Cookie?

Q81. What is the difference between session_unregister() and session_unset()?

Q82. What’s the meaning of $GLOBALS?

Q83. What’s the meaning of $_SERVER?

Q84. What is the difference between $_FILES[‘userfile’][‘name’] and $_FILES[‘userfile’][‘tmp_name’]?

Q85. What error do we get when there is a problem in uploading a file?

Q86. What does $_ENV mean?

Q87. What does $_COOKIE mean?

Q88. Explain the difference between the ‘BITWISE AND’ operator and the ‘LOGICAL AND’ operator.

Q89. What does the array operator ‘===’ means?

Q90. How do you determine whether a PHP variable is an instantiated object of a certain class?

Q91. Explain the difference between Exception::getMessage and Exception:: getLine

Q92. Can you parse a configuration file?

Q93. Explain the difference between the functions strstr() and stristr()?

Q94. Can you submit a form with a dedicated button?

Q95. Explain the difference between ereg_replace() and eregi_replace()

Q96. Explain the difference between characters \034 and \x34.

Q97. Can you extend the execution time of a PHP script?

Q98. Can you destroy a cookie?

Q99. Can you use COM component in PHP?

Q100. Discuss in detail whether it’s possible it’s to share a single instance of a Memcache between multiple PHP projects.

Want to ace your Python interview? Here are 100 Python interview questions you should prepare for.