Hiring a PHP programmer can be difficult, if you do not already have staff fluent in PHP. When selecting a candidate, it is often the case that no actually proof of programming ability has been obtained by the prospective employer, save for a quick call to a reference or two.

This, unfortunately, exposes the employer to candidates who believe they can do the job, but cannot, and those who are sufficiently desperate to apply to jobs that they know they cannot adequately perform. The end result, in either case, is an employee who does not carry their weight, and has to be eventually fired, but only after wasting valuable time and money of training and lost productivity.

Without existing PHP fluent staff to test such a candidate's competency, they may try to bluff their way through the interview. This article will help you avoid falling victim to this.

First, I recommend you ask the candidate to, with a pen and paper, write a PHP script that sorts a list. The candidate may ask for clarification, allow them to set their own standards. Questions are a good sign (this means the candidate wants to be sure to give you exactly what you want), a dumbfounded look is not (this means the candidate does not understand this very fundamental request). The candidate should finish quickly, and return to you up to a couple dozen lines of PHP code (less is sometimes better, but more usually reflects extreme inexperience). This will eliminate 95% of incompetent candidates. They will either not finish, take a very long time, produce far too much code, etc. The remaining 5% are good candidates, and those bold enough to try to bluff their way through this exercise.

Give these remaining candidates the following quiz. By completing this quiz successfully, and appearing to complete the written code task, you will have enough evidence to conclude that the candidate is a competent PHP programmer.

You should then make your choice based upon their claimed experience, references, and communication skills. Try describing the problems you want the prospective employee or contractor to solve, and see if the candidate can provide insight, or describe potential solutions.

PHP Programming Quiz:

This is a short programming quiz intended to determine basic competency with PHP.





Trivial Questions (end the interview if the candidate for the PHP programming position does not get all of these correct):

Which of the following is a syntactically valid variable name in PHP:

  1. #var
  2. $var
  3. var
  4. All of the Above

Correct Answer: B. $var

Is $Var the same as $var?

  1. True
  2. False

Correct Answer: B. False

Do modern versions of the PHP language contain object oriented features?

  1. True
  2. False

Correct Answer: A. True

Easy Questions (even the most junior PHP programmer should get all of these correct, do not consider a candidate that makes mistakes in this section except for the most entry level of PHP programming jobs):

What does the following function return, if the given input is 7:

  1. function foo($bar) {
  2. if ($bar == 1) return 1;
  3. elseif ($bar == 0) return 0;
  4. else return foo($bar - 1) + foo($bar - 2);
  5. }
  1. Nothing, a function cannot call itself in PHP
  2. 1
  3. 8
  4. 13
  5. 0
  6. 21

Correct Answer: D. 13

When translating from an untrusted user's input to a database query, it is important to:

  1. Interpolate user query
  2. Cache user query
  3. Sanitize user input
  4. Block XSS 

Correct answer: C. Sanitize user input.

Intermediate Questions (a mistake here may be acceptable for some non-advanced positions):

PHP is a _____ and _____ typed language.

  1. Statically, weakly
  2. Dynamically, weakly
  3. Statically, strongly
  4. Statically, weakly

Correct Answer: B. Dynamically, weakly

Which of these functions or keywords is involved in functions with a variable number of arguments?

  1. func_get_args()
  2. va_list
  3. *args
  4. get_va_list()

The correct answer is A. func_get_args()