views:

2991

answers:

13

We're having a PHP freelancer come by next week, and are assuming he knows his way around PHP. But of course, we would like to make sure. What questions would you ask a candidate in a PHP job interview?

Would you have them write some sort of bubblesort op paper, without the aid of a computer? Would you ask array-specific questions, OOP or SQL? I'd be interested to know how to pick out the good (PHP) programmer, without scaring them off with too many detailed questions.

+4  A: 

I would initially concentrate on security related features. If they don't understand the following then they've no place developing PHP code:

  1. Why is register_globals bad?

  2. What is a SQL injection attack

  3. How do you avoid them?

Alnitak
+8  A: 

What are some of the shortcomings of PHP that you've experienced and how did you deal with it?

mendicant
+3  A: 

I would definately also ask for security related questions such as how to execute intrusion safe SQL queries, prevent XSS attacks etc.

He should better also know his way around in modern frameworks and know good coding practices, such as Model-View-Controller and some design patterns that are relevant to PHP developers (Singleton, Registry, ...)

You should also make sure, that the developer has a solid foundation in HTML, CSS and JS. Even if they develop PHP most of the time they almost always have to do some HTML, CSS and eventually JS, so these are some things you can also ask for:

  • structured markup
  • valid xhtml + css
  • cross-browser compliance understanding
Sebastian Hoitz
+23  A: 
Noah Goodrich
That second set is right on target.
Abyss Knight
+5  A: 
  • When have you created your own OO code in PHP? (The answer will help you learn not only if the interviewee understands OO, but if they understand its limitations in the context of PHP.)

  • What optimization runtimes do you use with PHP? Can one combine them? Do you?

  • What was the single biggest bottleneck you removed from PHP code, and how did you find it?

  • When is it appropriate to shove PHP code into the template (e.g., Smarty) layer of the app.

  • What is an SQL injection? How do you avoid it?

  • Tell me your favorite IE6 nightmare story and how you solved it.

Joshua Fox
Haha, I like your last point, "tell me your favorite IE6 nightmare story"! Thats a good one! :D
Sebastian Hoitz
That last one isn't really specific to PHP though... well maybe for some of IE's weird behaviour with POST'ing button elements.
alex
> isn't specific to PHPQuite right, but in practice, ability to deal with IE6 is a major part of PHP programming,even though it is not part of the language.
Joshua Fox
+4  A: 

For me, I'd ask the following:

  • Demonstrate the use of variable variables and explain a case where they would be useful. (Or, if the terminology stumps the candidate show an example and ask them to trace it.)
  • Run them through a few standard interview questionnaires if you have access to them. The Disney Web Developer & Software Engineer questions are excellent. Basically, cover everything from the basics of JavaScript, Web Standards, CSS, and even some PHP. A good, basic PHP question to see how they find all numbers divisible by 5 for n=1 to 10. If they don't use the mod (%) operator then ask why.
  • Ask them what database abstraction layers they have used and if they have ever used a prepared statement. If so, ask them why. If they can't tell you why, then you have a problem. Security is something that can be easily ignored, but knowing is half the battle.
  • Frameworks. Sure, every candidate will name 12 different frameworks they have worked in. What if they haven't worked in a framework? What if they have never worked outside a framework? These are things you need to know depending on the code the freelancer will be working on.

Just a few ideas, but hope that helps. :)

Abyss Knight
I've been wanting to add this comment for a while, finally got my 50 points (yaay!!). I know what variable variables are, but I really cant think of an instance where they would be useful. I'd appreciate it if you can give me an example. Thanks!
sjobe
+3  A: 

Ok, a more serious answer.

The truth is, you don't need to do much to test his knowledge of PHP in specific. Understanding PHP is arguably a rather small part of being able to write robust and sound web applications.

What you really need is someone who understands how networks (especially TCP/IP) work, how web serving functions, the basic communication protocols that the web are built on, the dangers of accepting data from unverified (and verified!) sources, etc.

In other words, you want someone with coding experience who understands the underlying mechanisms by which the internet functions. Someone with web design experience can rattle off a list of potential security vulnerabilities. Only someone with a thorough understanding of how web communication functions can identify new vulnerabilities.

(And frankly, with any sufficiently advanced web program, chances are you'll create a new vulnerability. Sure, it'll be a new coat of paint on an age-old issue. But only someone with deeper understanding sees past the paint job.)

Jason L
Why can't you guys stop talking bad about PHP? It's not such a bad language anymore especially with PHP 5 many OOP features got introduced that allow you to develop complex object oriented applications. Yes there are many bad PHP scripts from newbies but I'm sure there also are from other languages.
Sebastian Hoitz
Full ack. PHP isn't that bad - but the fact that you need to find a good software developer and not specially a php developer is also true, it think that's what Jason L wants to say.
Endlessdeath
That might be true. But when reading his other post before it did not seem like it though. But you totally need to find a developer who understands writing good software!
Sebastian Hoitz
Oh yes, i didn't saw his first post at first. The post gets the voting it deserves :)
Endlessdeath
Actually, from the perspective of language design, PHP is a mess. My other comment was tongue-in-cheek and I didn't expect it to be taken so seriously, hence the parenthesis. But frankly, for me, if someone can't see the flaws in PHP's design then they're not that solid a programmer.
Jason L
+3  A: 

Also can be asked about:

  • PHP Frameworks (If he used one - Zend Framework, Cake)
  • String manipulation (He can explain concatenation)
  • Security (SQL Injection, XSS)
  • Client side programming (Javascript, Ajax).
  • Some PHP's built-in functions.
milot
+3  A: 

"What are some of the shortcomings of PHP that you've experienced and how did you deal with it?"

This is the BY FAR best question to ask I've ever heard since it shows that the candidate (if he can answer) knows more about system development then his "last PHP book"...

And the reason is that only a "thinking" person (and experienced in more than one programming language - which should be a qualification) can answer that question...

Though since few programmers will be able to give great answers to such a question, I wouldn't necessarily dismiss the candidate based on his inability to answer it, but I'd definitely prefer one being able to answer ;)

Thomas Hansen
+1  A: 

A few weeks ago i was in a similiar situation and the following link helped me to ask the right questions: The Guerrilla Guide to Interviewing

Endlessdeath
+7  A: 

It is my opinion that what should be accomplished in an interview is not an A to Z question and answer session trying to find every tidbit of PHP knowledge one has. There should be some well thought-out technical questions, not designed to show their flashy skills, but designed to expose the interviewee's thinking power.

For example:

Ask the interviewee to solve a technical problem, such as, "Given an array of integers from 1 to 1 million, write a function to determine which integer is missing in the range." At this point, give them a pen and paper (or white-board) and let them actually try to solve the problem. Don't rush them for time (but don't let them take all day either). You can prod them with ways to go about it, but above all make sure they are solving the problem. You can learn a lot about a programmer by how they deal with seemingly trivial problems, and how they deal with writing code under pressure.

Once you have finished that portion, ask them to optimize the code for speed and efficiency. If they had to cut the processing time by 25% or even 50%, how would they do it. At this point, it could just be conceptual. You may not even have a way to solve it yourself immediately, but this is irrelevant. Make the programmer THINK! I've found that when you ask questions that make a person step back and think, you learn much more about them than their resume or a "tell me why you're a good programmer" question will ever reveal.

As a side note, one question I have yet to ask in an interview (but can't wait to get the chance) is this:

"Having seen Google Maps, how would you duplicate or enhance the software design (objects, data structures, web services)?"

It's a super abstract question, and the actual answer doesn't really matter, I'm more interested in how they approach it.

localshred
A: 

Thanks everyone, all of these answers were really useful - too bad you can only tag one as the "solution". I greatly appreciate it, this will come in handy. :-)

Mojah