PHP job interview questions

Summary: A collection of PHP job interview questions (and other standard computer programming interview questions).

Over the years, I've found the best way to find out how a potential programmer works is to sit with him at a computer keyboard and write some code, typically something requiring some database interaction, and potentially interaction with another developer.

If I wasn't allowed to do that for some reason, I'd have to resort to the old process of sitting around and asking questions. With that in mind, I just put together this list of PHP job interview questions. If you're heading for a PHP job interview, I hope you'll find this list of questions helpful.

Basic PHP questions

I'd begin with basic PHP interview questions, making them progressively harder, or starting at different points, depending on what the interview candidate has told me about their background.

PHP developers constantly work with forms, arrays, dates, classes, algorithms, databases, and JavaScript, so I'd begin with those questions. Here are some PHP job interview questions I'd use to gauge a developer's programming experience:

  • What is difference between require_once(), require(), include()?
  • How do you perform a redirect in PHP? What problems can you run into when performing a redirect?
  • How would you convert a given string to a date?
  • What is the difference between echo and print? (I'm not thrilled with this question, but I might ask it in a light-hearted way to see how much "intellectual curiosity" a developer has about things like this.)
  • How does the PHP ternary operator work?
  • How would you print a date as a formatted string?
  • How do you place information in a session, and retrieve information from a session?

Demonstrate a simple PHP form, such as a login form, or a "user account information" form. (Related: What are GET, POST, and REQUEST?)

  • What security precautions do you need to take when writing a PHP form?
  • How can you increase the time limit of a PHP script?
  • How do you configure PHP so it won't show error messages on screen?
  • How do you increase the memory limit for a PHP script?
  • How do you create a persistent MySQL connection?
  • How do you create a file-upload page?
  • How do you create and use an array? How do you sort an array?
  • What is PEAR? (Followed by, What are some popular PEAR modules?)
  • What are some of the PHP regular expression functions?
    • How would I write an expression to match an email address or phone number?
    • How would I write a search and replace expression?
  • How do you debug your PHP programs?
  • What IDE(s) do you use? What's good and bad about them?

Some PHP job interview questions related to functions:

  • Write a basic function that accepts multiple arguments, does something with those arguments, then returns a value.
  • Demonstrate a function where you pass a variable by reference. Why would you pass a variable by reference (or value)?

PHP and object-oriented programming (OOP):

  • Have you use OOP with PHP? What are the benefits and drawbacks of OOP?
  • Write (or describe) a simple "Person" class.

SQL job interview questions

You can't write business applications without using a database of some sort, and MySQL, SQLite, and Postgresql are all popular open source databases. I'd ask questions related to SQL in general, then specific questions about whatever database the interview candidate has used before.

Here are some basic SQL questions:

  • How do you perform a simple SQL SELECT query?
  • How do you select individual columns in a SELECT query?
  • How would you write a join between multiple tables?
  • How would you write an UPDATE or DELETE statement?
  • Have you written any stored procedures? If so, explain how you wrote those. Also, what are the benefits and drawbacks of using stored procedures?

Source code control systems

These days a developer must know how to use source code control systems in a team environment. Therefore I'd ask questions about SVN, Git, or other SCCS, like these:

  • How do you create a new project in Git?
  • How you check in your changes in Git?
  • How do you revert your code to a certain day or time in Git or SVN?
  • What sort of problems have you had with Git or SVN when working with a team?
  • Have you worked on a project where you had a HEAD and branches? If so, tell me what you did, what was good, what was bad. (Looking for branching and merging experience.)

Automated build and testing systems

PHP developers must also be aware of build and integrated testing systems, so I'd ask questions like:

  • What PHP build systems have you used?
    • What are the benefits of automated build systems?
  • What automated testing systems have you used on PHP projects?
    • What errors are they best at catching?
    • When do these systems help?
    • Are they worth the time and effort?

With the last questions there, I'm interested in a person's experience "refactoring" PHP code. At some point I'll ask about their refactoring experience, either directly or indirectly.

Design patterns and MVC

I might ask a few questions about design patterns as they relate to PHP, though I'd mostly focus on MVC (Model View Controller).

Mostly what I'd be looking for here is how the candidate thinks about organizing a PHP application. That is, if they could write a PHP application from scratch, how would they organize it, and why?

PHP frameworks

I'd also ask what experience the PHP job interview candidate has with PHP frameworks, including:

  • Code Igniter
  • CakePHP
  • Symfony
  • Zend

These days Drupal is also a very important PHP framework. In fact, I might ask when the candidate would use Drupal compared to a different PHP MVC framework.

JavaScript and jQuery

I'd also ask questions about JavaScript and jQuery, but my own experience is still pretty light here, so I couldn't ask too many specific questions, but would focus more on what they could teach me in a few minutes. I've found this to be a good way of learning about someone's communication skills.

Working in a team environment

Twenty years ago many computer programmers worked alone, but these days most programmers work together on complex systems, and I always look for developers that work well in a team environment. I've found this to be a tough interview problem, but I'd ask questions about how the developer has worked on previous programming projects:

  • Tell me about programming projects you've worked on with other developers.
  • What were your roles?
  • What processes have you been involved with? (XP, Scrum, anything else.)
  • What worked well, what didn't work well?

Other PHP job interview questions

Depending on a job candidate's experience and the position they are interviewing for, I might ask other questions about scaling and performance, but I'll skip those here.

One other thing I should mention is that some companies take the tact of asking "thought" questions as opposed to direct programming questions. I remember a friend telling me that Microsoft asked a question about how to move colored balls between buckets, and things like that. Sometimes these questions are borderline puzzles. I suspect these questions are created to see what sort of problem-solver you are, and if so, I at least agree with the premise.

Finally, other questions that you may run into are the typical, "Where do you want to be in five years?", "How would you describe an ideal day?", and that sort of thing.

PHP job interview questions - Summary

In my experience as the owner of a computer programming consulting firm, the value of a programmer roughly increases as you go down this list:

The programmer:

  • knows the basics of a language
  • has a good "can-do" attitude at least 98 days out of 100
  • is a productive programmer and problem-solver on a consistent basis
  • knows the details of a language
  • adds re-usable code to the company's code library
  • works well as part of a team
  • communicates well with the "customer"
  • can run a software project successfully
  • can run a large software project successfully
  • can run multiple software projects successfully
  • is a thought-leader at the company

It sounds like a cliche, but besides wondering about whether a job interview candidate will be productive, my biggest concern was always, "Will he be a good team member?"

I hope these PHP job interview questions have been helpful. I thought about giving the answers here as well, but I think it's better to just share the questions. If you'd like to share your own favorite job interview questions, just leave a note in the Comments section below.