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
- 5 basic PHP interview questions and the answers to listen for
- 35 intermediate PHP interview questions
- 5 intermediate PHP interview questions and the answers to listen for
- 39 advanced PHP interview questions
- 5 advanced PHP interview questions and the answers to listen for
- When during the hiring process should you ask candidates PHP interview questions?
- Why is skills testing a top recommendation during the hiring process?
- ✅ Make skills testing as part of your hiring process of PHP developers
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.
- Explain what PHP is.
- Does the PHP coding language resemble any others?
- What is the difference between variables and constants?
- Explain what a session is in PHP.
- Explain what PEAR means.
- Is the PHP language case sensitive?
- Outline three PHP variables.
- Which rules must be used when naming variables in PHP?
- Explain the difference between “print” and “echo.”
- What are some advantages of PHP?
- What are some disadvantages of PHP?
- Which technical skills do you need to use PHP?
- Which soft skills do you need to use PHP in a team of developers?
- Can PHP interact with HTML?
- Name three uses of PHP.
- Describe how dynamic and static websites are different.
- Explain what “NULL” means.
- What is meant by defining constants, and how would you do this in PHP?
- What does the “break” statement do?
- What does the “continue” statement do?
- How are PHP4 and PHP5 different?
- What is meant by single inheritance in PHP?
- Does PHP support multiple inheritance?
- What does the GD library do in PHP?
- What does “imagetypes()” do?
- 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.
- What is the advantage of PHP interacting with HTML?
- What does “@” do in PHP?
- How important is a parser in PHP?
- Outline three types of arrays in PHP
- Describe the three main error types in PHP.
- Explain what traits are.
- How is “include()” different to “require()”?
- Explain what cookies are and how to create them in PHP.
- Explain how PHP is different from ASP.NET.
- Explain what “escaping to PHP” means.
- Explain what “final method” means in PHP.
- Which arrays does PHP support?
- What are indexed arrays?
- What are associative arrays?
- How are associative arrays different from indexed arrays?
- What are multidimensional arrays?
- How is “require()” different from “require_once()”?
- How would you set an infinite execution time in PHP?
- What do constructors do?
- What do destructors do?
- Name some of the best content management systems that work using PHP.
- How would you make a comment in PHP?
- How would you hash a password in PHP?
- When would you use the “file_get_contents()” function?
- What does “mysql_pconnect()” help you do?
- What does the “empty()” function do?
- What does the “unlink()” function do?
- What does the “strip_tags” function do?
- What does the “unset()” function do?
- What does the “static variable” function do?
- What does “crypt()” do?
- What does the “goto” statement help you to do?
- How is “strstr()” different from “stristr()”?
- 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.
39 advanced PHP interview questions
Use the 39 advanced PHP interview questions below to learn more about your senior developers’ skills.
- How can you use MySQL and PHP to make a new database?
- Explain what “session_start()” means.
- Explain what “session_destroy” means.
- Explain what “memcache” means.
- Describe what the Memcached system is.
- What does “mysqli_fetch_array()” do in PHP?
- What does “mysqli_fetch_assoc()” do in PHP?
- What does “mysqli_fetch_object()” do in PHP?
- What does “mysqli_fetch_row()” do in PHP?
- Which steps would you take to create a PHP API?
- What is the difference between “POST” and “GET”?
- Describe what overloading means in PHP.
- Describe what overriding means in PHP.
- In PHP, how is “$message” different from “$$message”?
- What does “callback” do in PHP?
- Explain what the “lambda” function does.
- Explain what “magic functions” do.
- Give three examples of the main magic functions.
- How do you carry out password encryption in PHP?
- Explain what type hinting is.
- Explain how compile time exceptions are different from runtime exceptions.
- Does PHP support typecasting?
- Does PHP support variable length arguments?
- How would you open a file using PHP?
- Can URLs connect to PHP? How?
- How does Java compare with PHP?
- How would you submit forms if there was no submit button in PHP?
- Explain what Zend Engine is.
- Explain what “.htaccess” is.
- Why is “.htaccess” used?
- What is meant by Smarty?
- Explain what “soundex()” is.
- Explain what “metaphone()” is.
- What is the ternary conditional operator?
- How would you share a single memcache instance with various projects in PHP?
- How is “foreach” different from “for”?
- Explain what “$_SERVER” means.
- Explain what “$GLOBALS” means.
- 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.