58

My company needs to hire a PHP developer, but nobody has PHP knowledge in my company and we find difficult to test for PHP skills. If it were a C/Java developer I would ask him to write a quick implementation of the Game of Life, but PHP is a completely different language.

I saw this test with interest:

http://vladalexa.com/scripts/php/test/test_php_skill.html

Anyone else has more suggestions?

Mascarpone
  • 765
  • 1
  • 6
  • 8
  • 3
    Interesting test, doesn't cover SQL injection though which I would certainly cover. I guess that test's a good way to test their ability to determine their familiarity with how PHP treats variables and not much else. – Ben Brocka Nov 09 '11 at 23:28
  • 6
    Whatever you do, don't ask questions regarding the spelling of standard function names. PHP function naming is so inconsistent. – Chris C Nov 09 '11 at 23:55
  • 1
    Possible duplicate of http://programmers.stackexchange.com/questions/46274/need-php-interview-questions-and-answers – Adam Lear Nov 10 '11 at 00:01
  • 16
    I would worry less about their PHP chops and more if they can program, work with the team, understand web security, etc. – Peter Loron Nov 10 '11 at 01:14
  • and how could I test that? Could you suggest some questions? – Mascarpone Nov 10 '11 at 01:17
  • 1
    @Mascarpone Ask them about XSS (Cross Site Scripting), XSRF (Cross Site Request Forgery), SQL Injection, lack of proper server-side data validations, etc. Write up some basic examples of these security holes and ask them to find as many issues as they can. – binarycleric Aug 09 '12 at 12:59
  • 12
    If nobody of your company knows PHP well, then the best way for you is to use some skills testing service. [http://tests4geeks.com/test/php-mysql](http://tests4geeks.com/test/php-mysql) - I like this one. And then, if the result will be good, you can ask him to write some PHP code. For example, there are students and subjects in database. Ask him to write the HTML-form, where the director edits the marks in the table (Students are in left column, Subjects are in top row, Marks are at the intersection). – Joseph Apr 15 '13 at 10:56
  • @Joseph I came across that site a little earlier and it looks really helpful! – Ananth Apr 15 '13 at 13:33

3 Answers3

71

Code

  • Ask the candidate to write code
  • Ask the candidate to read code

If you do ask the candidate to write code make sure that:

  • The code is non trivial but small
  • You allow access to the manual and the internet

If you do ask the candidate to read code make sure that:

  • The code has some trivial errors
  • The code has some non trivial errors
  • The code works fine, but it can be easily optimized

You can use three or more different pieces of code, start from the simpler one and only advance to the next if you see that the candidate copes with ease. Throw in some recursion, to spice things up.

Resources

Ask for a detailed list of PHP resources the candidate uses. Books, blogs, forums, magazines, etc. That's how my current employers found out about StackOverflow.

If the candidate mentions StackOverflow or Programmers, you should NOT ask or try to find out their username. If they wanted to advertise their reputation they would have included a Careers 2.0 link on their resume.

Frameworks

Every PHP developer should know of the most popular PHP frameworks:

and be fluent in at least one of them. You can have a few code samples ready for each one and ask the candidate to read and explain them, after they tell you which one they are more familiar with.

Debugging & Profiling

I've always felt that PHP developers are lacking debugging and profiling skills (perhaps only the PHP developers I've worked with). If during the discussion you find out that the candidate actively uses xdebug, don't bother with the rest of the interview and just hire them. ;)

Input sanitization

This is important. You can start with a discussion on why it's important and then ask for the most common methods to achieve it. This discussion will help you on what to ask.

Some hints:

PHP snafus

You can find a lot of PHP snafus in this excellent discussion. If you are interviewing for a senior position you should definetaly ask on some of those. Some examples:

PHP's handling of numeric values in strings:

"01a4" != "001a4" // true
"01e4" == "001e4" // also true

Valid PHP code:

System.out.print("hello");

In PHP, a string is as good as a function pointer:

$x = "foo";
function foo(){ echo "wtf"; }
$x(); # "wtf"   

Unit testing

Need I say more?

Conclusion

A good PHP developer should combine a variety of skills & talents:

  • A good understanding of HTTP
  • A good understanding of Apache configuration (Even if you use a different web server at your company)
  • At least a basic understanding of JavaScript
  • A great understanding of HTML / CSS

The list goes on and on. Make sure you tailor the interview to the specific needs of the job opening, you don't want to hire just a good developer but a good developer that's great at what you immediately need him / her to do.

yannis
  • 39,547
  • 40
  • 183
  • 216
  • 22
    Good answer overall, but I disagree on the 'frameworks' part and the 'basic performance' part. Whether you know a certain framework or not doesn't say much about your qualities as a programmer. About the performance part: if you're optimizing at this level, you probably shouldn't be using PHP in the first place. I make choices between the alternatives you list dozens of times each day, but always based on readability and functionality, not performance. The correct answer to these performance questions is "it doesn't matter most of the time." – tdammers Nov 10 '11 at 06:49
  • @tdammers `Whether you know a certain framework or not doesn't say much about your qualities as a programmer.`: Yes, but it makes it easier to integrate yourself in a team. Most teams I've work with used some kind of framework (floss or in house). As for the performance, I totally disagree with you on all points: The optimizations can save you a lot of grief on several common scenarios, like big imports / exports. And properly optimized PHP is a fantastic platform to work on, I wouldn't change it for anything. And never found a valid reason to do so. – yannis Nov 10 '11 at 06:57
  • 1
    @YannisRizos: While it most likely makes it easier to integrate in a team you are assuming that in the OP's company they use one of these popular frameworks, but if they are not then knowing either of the frameworks would prove nothing. Perhaps you meant this part as a way to test his ability to work with *a* framework rather than with *those* frameworks? (Point in case: in the company I work for we use an in-house developed framework) – Purefan Aug 17 '12 at 06:42
  • I disagree with `you should NOT ask or try to find out their username`. If they are on SO, and don't want to show you their profile, then they are hiding something. Likewise many employers ask to see FB accounts and the like. – Petah Aug 18 '12 at 13:29
  • 2
    @Petah That doesn't make any sense at all, especially at the interview stage and I would avoid working at a company that asks people to reveal information like that during the interview. The whole "hiding something" reasoning is perverse, imho, I don't care for my employer knowing how I spend my free time, and that's just about it. If I'm interested in publicizing my Programmers account on my own, that's a different story... – yannis Aug 18 '12 at 13:35
  • Personally I have never asked for this information, but have been asked. I do somewhat agree that if I am going to spend 25%-35% of my time with someone then I would like to know a bit about there personality before I commit to it. – Petah Aug 18 '12 at 13:40
  • 1
    @Petah Well I honestly hope future employers don't try to get to know my personality through my Programmers activities (who would want to spend 25%-35% of their time with an evil nazi mod ;) – yannis Aug 18 '12 at 13:41
  • 1
    Disagree with the framework thing. Good, modern practice is to use applicable components from frameworks using composer that you require rather than using an entire framework. In fact, the same can be said in the JS world now too.. – John Hunt Oct 27 '15 at 14:09
  • @Yannis just wondering what if the person doesn't know any framework and just php – localhost Jan 17 '16 at 12:36
  • "01e4" == "001e4" is NOT true. They will be compared as strings and will return false. – Razvan Apr 19 '17 at 17:14
  • This would be useful: http://bayanbox.ir/view/6170521268076111481/PHP-Backend.jpg – Yousha Aleayoub Dec 06 '18 at 06:50
44

The test you linked to is interesting, and Yannis Rizos's answer is great, but I think what is also important is this:

If you need a good developer do not look for PHP developer. Look for a good developer who knows PHP. That means, at least half of the interview you should be asking questions that do not have much to do with PHP syntax or PHP functions.

Ask him what is MVC, what is AJAX, how HTTP works, how REST works, how SQL joins work, some data structures, some performance basics (how you measure, how you improve), testing basics, security basics (XSS, XSRF, injections, how you defend), basic programming craft knowledge as applied to typical PHP domains - web, networking, data transformations, etc.

If he's good on that, proceed to asking him to write some simple code, pick some easy task that should not take long - like finding words with most vowels in a row in the text, or reversing each word in the text, or multiplying two matrices. You can also ask him to implement the Game of Life in PHP, if you like :)

If he passes that, then you can proceed to more tricky PHP questions, but don't put too much weight into this. He can read most of it in the manual, and what he can't read, he'll learn quite quickly if he's good. PHP is built to be simple, so if he's a good programmer, and has some working knowledge of PHP, he'll probably be able to catch up. If he knows how to program in general, then learning how to program in PHP is easier than the reverse - knowing PHP syntax minutia is not important if you don't understand what unit tests are for or how to get rid of XSS problems.

StasM
  • 3,377
  • 2
  • 23
  • 28
13

While Yannis Rizos's answer is a good one - I know I wouldn't pass that test and I might use that answer as a resource to determine where to focus to improve my PHP chops, I think it would be worth your while to find a programming buddy who knows PHP to sit in on the interview process. All the questions in the previous answer are good, but without some domain knowledge it's going to be hard to assess the quality of the answers.

That said, depending on what you need as others have said general programming facility and team fit are probably more important than language-specific knowledge.

cori
  • 591
  • 3
  • 14
  • 5
    +1 for `I think it would be worth your while to find a programming buddy who knows PHP to sit in on the interview process.`, great suggestion. – yannis Nov 10 '11 at 14:08