100 PHP interview questions to ask your candidates

The best advice in pre-employment testing, in your inbox.

No spam. Unsubscribe at any time.
Close
CTA

Hire the best. No bias. No stress.

Our screening tests identify the best candidates and make your hiring decisions faster, easier, and bias-free.

Try for free
Close

100 PHP interview questions to ask your candidates

featured image of php interview questions to ask candidates

Selecting between PHP developer candidates for your team can be difficult, but there are two ways to ensure you make the right decision. 

When you start sourcing candidates, you should ask them to complete an initial skills assessment that includes a PHP skills test. Once you’ve narrowed down your candidate list with the skills assessment results, ask your remaining applicants specific PHP interview questions to evaluate them further.

These two steps will make your hiring process faster and bias-free.

To make things easier, we’ve put together this list of 100 PHP interview questions you can ask candidates to make sure you hire great developers.

Take a look at the questions below and select those most appropriate for your open role to include in your interview process.

Table of contents



26 basic PHP interview questions

The section below has 26 basic PHP interview questions that you can include in your interview process when hiring junior and mid-level PHP developers.

image of basic PHP interview questions

  1. Explain what PHP is.
  2. Does the PHP coding language resemble any others?
  3. What is the difference between variables and constants?
  4. Explain what a session is in PHP.
  5. Explain what PEAR means.
  6. Is the PHP language case sensitive?
  7. Outline three PHP variables.
  8. Which rules must be used when naming variables in PHP?
  9. Explain the difference between “print” and “echo.”
  10. What are some advantages of PHP?
  11. What are some disadvantages of PHP?
  12. Which technical skills do you need to use PHP?
  13. Which soft skills do you need to use PHP in a team of developers?
  14. Can PHP interact with HTML?
  15. Name three uses of PHP.
  16. Describe how dynamic and static websites are different.
  17. Explain what “NULL” means.
  18. What is meant by defining constants, and how would you do this in PHP?
  19. What does the “break” statement do?
  20. What does the “continue” statement do?
  21. How are PHP4 and PHP5 different?
  22. What is meant by single inheritance in PHP?
  23. Does PHP support multiple inheritance?
  24. What does the GD library do in PHP?
  25. What does “imagetypes()” do?
  26. How would you export data in PHP to Excel?



5 basic PHP interview questions and the answers to listen for 

Here are a selection of the basic PHP interview questions above and the answers you’ll want to look out for from your candidates.

1. Explain what PHP is.

This is a fundamental question that all PHP developers should be able to answer. Are they aware that PHP helps developers write dynamic code using scripts to create web pages and that it’s an open-source language? Can they explain that PHP is an acronym that stands for hypertext pre-processor?

2. Name three uses of PHP.

It’s essential that junior candidates know some of the main uses of PHP. For instance, candidates may mention that PHP allows them to:

  • Manipulate databases 
  • Access cookies
  • Do system function actions, including read and write
  • Handle forms with file-handling features

3. Does the PHP coding language resemble any others?

Candidates should recognize that PHP does resemble other coding languages. They may mention that its syntax is similar to the C coding language and Perl.

4. Explain what PEAR is.

The acronym PEAR means PHP extension and application repository. Junior PHP developer candidates should be able to outline the main uses of PEAR, which include:

  • Access to open-source code in a structured library
  • Package maintenance and distribution of code in an efficient system
  • An established style that makes writing code easier in PHP

5. Can PHP interact with HTML?

Candidates who understand PHP at a basic level should know that PHP can interact with HTML. They may explain that, even though PHP is used for dynamic pages and HTML for static pages, scripts in PHP can be run in HTML mode. 

35 intermediate PHP interview questions

The following 35 intermediate PHP interview questions are ideal for hiring mid-level PHP developers. 

35 intermediate PHP interview questions

  1. What is the advantage of PHP interacting with HTML?
  2. What does “@” do in PHP?
  3. How important is a parser in PHP?
  4. Outline three types of arrays in PHP
  5. Describe the three main error types in PHP.
  6. Explain what traits are.
  7. Can PHP interact with JavaScript?
  8. How is “include()” different to “require()”?
  9. Explain what cookies are and how to create them in PHP.
  10. Explain how PHP is different from ASP.NET.
  11. Explain what “escaping to PHP” means.
  12. Explain what “final method” means in PHP.
  13. Which arrays does PHP support?
  14. What are indexed arrays?
  15. What are associative arrays?
  16. How are associative arrays different from indexed arrays?
  17. What are multidimensional arrays?
  18. How is “require()” different from “require_once()”?
  19. How would you set an infinite execution time in PHP?
  20. What do constructors do?
  21. What do destructors do?
  22. Name some of the best content management systems that work using PHP.
  23. How would you make a comment in PHP?
  24. How would you hash a password in PHP?
  25. When would you use the “file_get_contents()” function?
  26. What does “mysql_pconnect()” help you do?
  27. What does the “empty()” function do?
  28. What does the “unlink()” function do?
  29. What does the “strip_tags” function do?
  30. What does the “unset()” function do?
  31. What does the “static variable” function do?
  32. What does “crypt()” do?
  33. What does the “goto” statement help you to do?
  34. How is “strstr()” different from “stristr()”?
  35. Explain what “$_FILES” means.



5 intermediate PHP interview questions and the answers to listen for 

Here are five selected intermediate PHP interview questions from the list above and the answers you might expect during the interview process.

1. What is the advantage of PHP interacting with HTML?

Since PHP is a scripting language used on the server-side and HTML is a language used on the client-side, the main advantage of their interaction is that it brings together both server and client sides. It makes it easier to provide content from a database to an HTML web page and display the content there. 

2. How important is a parser in PHP?

Parsers can be useful for converting source code into a code type that a computer understands. Mid-level candidates should know that the code, which is written in PHP, goes through a lexical analyzer. Once it has passed through the analyzer, the parser builds a syntax tree, which is handy for developers to check static code for errors.

3. Describe three main error types in PHP.

Are your candidates aware that the three main PHP error types are notices, warnings, and fatal errors? Can they explain what each of these PHP error types means? For instance, whereas notices are not considered critical and aren’t shown to the user, both warnings and fatal errors are displayed, and fatal errors can cause the script to terminate.

4. Which arrays does PHP support?

Your candidates might mention three main arrays when responding to this question: indexed arrays, associative arrays, and multidimensional arrays. 

Mid-level developers should know that indexed arrays contain numerical data, associative arrays contain strings used for element indexing, and multidimensional arrays contain multiple dimensions and indexes.

5. Can PHP interact with JavaScript?

In the same way that PHP can interact with HTML, PHP can also interact with JavaScript. Candidates should understand that PHP can create JavaScript variables that you can run in a browser. They should also understand that a URL makes this possible. 



39 advanced PHP interview questions

Use the 39 advanced PHP interview questions below to learn more about your senior developers’ skills.

image showing advanced PHP interview questions

  1. How can you use MySQL and PHP to make a new database?
  2. Explain what “session_start()” means.
  3. Explain what “session_destroy” means.
  4. Explain what “memcache” means.
  5. Describe what the Memcached system is.
  6. What does “mysqli_fetch_array()” do in PHP?
  7. What does “mysqli_fetch_assoc()” do in PHP?
  8. What does “mysqli_fetch_object()” do in PHP?
  9. What does “mysqli_fetch_row()” do in PHP?
  10. Which steps would you take to create a PHP API?
  11. What is the difference between “POST” and “GET”?
  12. Describe what overloading means in PHP.
  13. Describe what overriding means in PHP.
  14. In PHP, how is “$message” different from “$$message”?
  15. What does “callback” do in PHP?
  16. Explain what the “lambda” function does.
  17. Explain what “magic functions” do.
  18. Give three examples of the main magic functions.
  19. How do you carry out password encryption in PHP?
  20. Explain what type hinting is.
  21. Explain how compile time exceptions are different from runtime exceptions.
  22. Does PHP support typecasting?
  23. Does PHP support variable length arguments?
  24. How would you open a file using PHP?
  25. Can URLs connect to PHP? How?
  26. How does Java compare with PHP?
  27. How would you submit forms if there was no submit button in PHP?
  28. Explain what Zend Engine is.
  29. Explain what “.htaccess” is.
  30. Why is “.htaccess” used?
  31. What is meant by Smarty?
  32. Explain what “soundex()” is.
  33. Explain what “metaphone()” is.
  34. What is the ternary conditional operator?
  35. How would you share a single memcache instance with various projects in PHP?
  36. How is “foreach” different from “for”?
  37. Explain what “$_SERVER” means.
  38. Explain what “$GLOBALS” means.
  39. What is meant by propagating a session id?



5 advanced PHP interview questions and the answers to listen for

Here are five advanced PHP interview questions and the answers to listen for during the interview process.

1. Explain what type hinting is.

Type hinting is a function used in PHP to define an argument’s data type clearly. The function instigates a check on the specified data types and searches for differences between the specified type and the data type. If there are differences, PHP will stop the execution and produce an error.

2. How does Java compare with PHP?

There are a few points candidates may mention when comparing Java with PHP. The first is the area of deployment. PHP’s area of deployment is server-side, whereas Java’s is for programming in a general sense. 

The second is the language type. Candidates could mention that whereas PHP is dynamic, Java is a static language type.

The third is the type of API. Candidates may mention that PHP doesn’t provide rich APIs, whereas Java does.

3. Can URLs connect to PHP? How?

The simple answer is that, yes, URLs can connect to PHP. Senior-level PHP developers should know that they can use a “cURL” to connect a URL to PHP. They should also be able to explain that a “cURL” is a client-side URL and a default library that is part of PHP. 

4. How would you open a file in PHP?

There are many file-related functions in PHP that developers use for file operations. Candidates should know that “fopen()” is the function that opens files in PHP. They may explain that the “$filename” and “$mode” arguments form parts of this essential function.

5. Does PHP support typecasting?

Senior-level PHP developers should know that PHP does support typecasting. They will be able to provide examples that show which data types can be cast and how this is done. For instance, the developer must specify the output in parentheses to indicate which output is expected, such as bool to Boolean.



When during the hiring process should you ask candidates PHP interview questions?

It’s best to carry out interviews and ask candidates PHP interview questions after you’ve received the results of their skills assessments.

It’s a good idea to do it in this order so you can immediately eliminate candidates from the hiring process if the skills assessment shows they’re not a good match.

You can then invest the right amount of time interviewing candidates you already know have the PHP skills for your vacancy and avoid interviewing candidates without the required skills.



Why is skills testing a top recommendation during the hiring process?

Skills testing is a thorough process that will help you keep time-to-hire low. It also helps you avoid relying on resume screening, which can give you inaccurate information about your candidates’ abilities.

When you combine skills tests with PHP interview questions, you create a comprehensive hiring process that helps you hire the best talent for your team.

Hire top PHP developers with our comprehensive list of PHP interview questions

Despite the challenges of finding and hiring the right PHP developers, a simple combination of the right PHP interview questions and skills assessments will make the process effortless.

With the PHP interview questions listed in this article and the skills tests from TestGorilla, you’ll have no problems hiring excellent candidates.

Try TestGorilla today and start hiring top PHP developers.

Leave a comment

Hire the best candidates
with TestGorilla.

Create pre-employment assessments in minutes to screen candidates, save time, and hire the best talent.

Try for free

Free resources