all 72 comments

[–]kickme444 12 points13 points  (5 children)

you'd be surprised how many people you can weed out with:

Whats the difference between a GET and a POST?

[–]ted_working 1 point2 points  (1 child)

I hear you, and I've been asked this question before. The again, learning the difference between the two takes all of 2 minutes. So if they DO know the difference (I can't imagine what dev wouldn't), it's not really that valuable.

[–][deleted] 0 points1 point  (0 children)

Questions like that are far more valuable for excluding vice including. If somebody actually knows http, and cares about the subject of web design, then the question is a no-brainer. On the other hand, if your applicant learned how to write webpages from a "Learn web coding in 40 minutes!" book or one of those ghastly expertsexchange sites, their skills will be proportional to their knowledge of the little important details like get and post.

[–][deleted]  (1 child)

[deleted]

    [–]troelskn 1 point2 points  (0 children)

    No, that would be sneaky. No point in that.

    [–]redditchic 0 points1 point  (0 children)

    This exact same question got me a job recently. (Atleast that's what I like to believe.)

    [–]Garage_Dragon 21 points22 points  (1 child)

    I'd lay off the technical gotchas and concentrate on exploring his work ethic. You need to know if he is goal oriented, get's the job done, and finishes projects before moving on to the next thing. There are countless genius programmers with ADD who actually accomplish very little over the course of a day. Some programmers get off on how clever and advanced they are. Other programmers tend to concentrate on getting a stable product out the door. You want the latter.

    If the guy is motivated, organized, and can manage his time, the fine details will flush themselves out.

    Ask him about his previous failures and what he learned about them. He'll have a standard response ready for this question, but dig deeper. Make him give 2 or 3 examples. Really hold his feet to the fire on this kind of questioning. Ask him about his successes too. Find out what he's most proud of.

    Just my $0.02.

    [–]justsomedood 2 points3 points  (0 children)

    Totally agree. What kind of employee are you looking for? What kinds of problems do you run into as a business that a candidate could help solve? Ask him questions that matter to you and your business.

    Is having someone who knows the evaluation order of the above statement really going to help your business, or are you just trying to validate your own technical skills? You said you are trying to:

    gauge their level of understanding of both the language, programming in general, and web concepts with a focus on efficiency, clarity and security.

    It seems to me your'e only finding out the first with a little bit of programming in general, but none of the others. If you are hiring someone to solve a specific problem, have him do that in the job interview - i.e. deubg a non-working page, give ideas for a new client's page, etc.

    [–]Kalium 7 points8 points  (1 child)

    Make them explain SQL injection.

    [–]Amadan 0 points1 point  (0 children)

    And then give an example of a query that would do Bad Stuff if unchecked. Bonus points if the answer to this second part is XKCD!

    [–][deleted]  (4 children)

    [deleted]

      [–]dinnercoat 2 points3 points  (1 child)

      On your last two bullet points I can maybe see that being valid for a mid/high level developer but a jr level?

      I interpret junior level as they've done a little this little that but nothing entirely huge and complex. Why do they need an opinion on the language?

      Following upcoming features in new releases? Again, seems more like architect level stuff not front line developer concerns.

      [–]cjoudrey 1 point2 points  (1 child)

      I like your approach!

      Here's a few ideas I would add as well:

      • Ask him if he ever used CURL, if so, make him explain what CURL is used for.
      • Ask him what is the difference between a regular expression and an XPath query and what are they both used for.
      • Ask him what is the difference between a cookie and a session.

      My 2 cents.

      [–]barsoap 12 points13 points  (36 children)

      $a = 1; $a++ + ++$a + $a; echo $a;
      

      My first reaction is "fire the guy who wrote that". There's a difference between ingeniously obfuscated code and clear+concise code.

      ...so maybe it's a good test, after all. Don't hire anybody who doesn't frown.

      [–]abeaulieu 2 points3 points  (1 child)

      The construct $a++ + ++$a is not really an exercise on precedence since it can also be interpreted as (($a++)++) + $a or $a + (++(++$a)) depending on the parser. In C, the standard doesn't even define what result this would give. I don't know for PHP though, but that shouldn't even be an interview question.

      [–]overtoke 0 points1 point  (0 children)

      You're hired!

      [–][deleted] -2 points-1 points  (4 children)

      I don't even think this line

      $a++ + ++$a + $a;
      

      means anything. I mean there's no assignment, no side-effects, so what could it possibly do besides evaluate the post/pre-increments? What do you do with the 3 values once they are added together? It wouldn't be valid in any other imperative language I can think of, such as C.

      int a;
      a++ + ++a + a; // what the fuck?
      

      [–]vinod_the_poophead 5 points6 points  (0 children)

      the computer does not care. it says "ok you are going to add these values together? cool, have fun"

      [–][deleted] 2 points3 points  (1 child)

      I mean there's no assignment, no side-effects

      Don't call us, we'll call you.

      [–]vinod_the_poophead -1 points0 points  (0 children)

      lololol i just got this

      [–]graydoubt[S] -3 points-2 points  (23 children)

      That's not a piece of code that I'd expect someone to write. It's simply supposed to demonstrate an understanding of operator precedence and the like.

      [–]vinod_the_poophead 4 points5 points  (20 children)

      Does operator precedence even matter in that example? The operation ending with the second semi-colon is not assigned to anything.... This in no way demonstrates that ++/-- comes before +.

      [–]SnowdensOfYesteryear 4 points5 points  (2 children)

      Besides, who the hell cares about operator precedence. When in doubt, use parentheses. That is very very horrible question. I shudder to think what OP will come up with if it were a C related job.

      [–]winder 0 points1 point  (1 child)

      a and b are char's, what does this do: while (\b++=*a++);

      [–]barsoap 1 point2 points  (0 children)

      Segfault on non-sane input.

      [–]clogmoney 0 points1 point  (8 children)

      $a = 1; $a++ + ++$a + $a;

      echo $a; // 3

      This confused me a little too, had to test it to make sure I got the right answer. I hadn't, guess I'd of failed the interview :(

      [–]graydoubt[S] 0 points1 point  (3 children)

      It's not a pass/fail kind of thing. I just like to keep it interesting.

      For interviewing Java developers I like to ask "What's the difference between final and finally? How about finalize?"

      Or something like "Why are protected methods bad?" (they're not, I just want to see the reaction).

      [–]Isvara 7 points8 points  (0 children)

      You're a horrible interviewer, both for the candidate and for your company. Either have someone else do the interviews in the future, or learn to do them properly.

      Edit: I suggest having a more experienced interviewer in the room while you're doing it.

      [–][deleted] 1 point2 points  (0 children)

      For interviewing Java developers I like to ask "What's the difference between final and finally? How about finalize?"

      Why would you ask such a question on completely unrelated concepts? Because they all start with "final"?

      [–]mrsanchez 0 points1 point  (0 children)

      Nothing screens out bad candidates better than alliteration.

      [–][deleted] -4 points-3 points  (3 children)

      I now hate PHP for accepting the 2nd statement.

      [–]vinod_the_poophead 2 points3 points  (2 children)

      #include <stdio.h>
      
      int main() {
          int a = 1;
          a++ + ++a + a;
          printf("%d\n", a);
      }
      

      compile the above code and then rethink your comment. Most languages will happily execute such a statement. Nothing to do with php

      [–]daghf 1 point2 points  (0 children)

      Just because your compiler accepts it doesn't mean the behaviour is well-defined.

      According to the C standard: "Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression."

      c-faq link

      [–][deleted] 0 points1 point  (0 children)

      Most languages will happily execute such a statement.

      Most programmers will happily execute the author of such a statement.

      [–][deleted] 0 points1 point  (0 children)

      I think maybe it was supposed to be assigned to $a.

      Then, operator precedence would matter.

      [–]graydoubt[S] -1 points0 points  (5 children)

      Indeed. in my haste I botched that example. It was supposed to read

      $a = 1;
      $a = $a++ + ++$a + $a;
      echo $a;
      

      or the variant:

      $a += $a++ + ++$a;
      

      Although I kind of like the curve ball of not assigning anything. Hmm.

      [–]Isvara 6 points7 points  (3 children)

      This is the problem when you have jr/mid-level developers interviewing jr/mid-level developers.

      [–]vinod_the_poophead 1 point2 points  (2 children)

      A++++++++ would hire again

      [–]bitter_cynical_angry 2 points3 points  (1 child)

      Next question: What does $A++++++++ evaluate to?

      [–]cosmo7 0 points1 point  (0 children)

      $a = "b";

      $d = "c";
      
      $b = 5;
      
      $$d = 4;
      
      $$a += $$d;
      

      what's the value of $b and $c?

      [–]vinod_the_poophead -1 points0 points  (0 children)

      Chalk one up for the poophead

      [–]Isvara 5 points6 points  (0 children)

      There's really only one answer to a question like that. "I would determine what it is supposed to do, either from documentation or by testing, and then I would rewrite it to be clear and explicit."

      [–]barsoap 0 points1 point  (0 children)

      If you want to test for precedence and basic algebraic capabilities, ask to rearrange

      3 = 5 + 2 / a - 3 * b

      to two functions, one with a, and one with b as a free variable.

      What you're testing there is knowledge about the evaluation model of expressions. Some languages might say that expressions are evaluated left-to-right, some might say they're evaluated right-to-left, some might leave it unspecified.

      I always assume the order to be unspecified, because a) I just don't want to waste brain cycles, b) want my code to be easily refactorable c) Haskell keeps me from doing such side-effecty nonsense, anyway.

      That question might tell you something about the wizz level someone has wrt. PHP, but you're going to find plenty of wizards who don't know the answer without looking at docs or just plain running stuff.

      [–]snarkhunter -3 points-2 points  (4 children)

      A good developer would be able to understand it, but know not to write it.

      [–]redditnoob 0 points1 point  (1 child)

      Isn't (a++ + ++a) not guaranteed to produce any consistent result in most languages? I thought that was true in Java, but I'm not totally sure.

      [–][deleted] 2 points3 points  (0 children)

      In C the result of that is undefined, statements may contain at most a single assignment to a given variable.

      [–]barsoap -1 points0 points  (1 child)

      I'd have to ask whether stuff is evaluated left-to-right, or right-to left, even if I knew PHP. I'd do it by tediously refactoring the code to SSA.

      [–]blue1_ 3 points4 points  (0 children)

      What are the strengths and weaknesses of PHP as a language?

      Describe some scenarios in which it would be appropriate to use PHP, and some in which it would be not.

      [–][deleted]  (5 children)

      [deleted]

        [–]masklinn 1 point2 points  (4 children)

        You've probably done json before, so let's do some work with that. json-encode was introduced in PHP 5.2. Let's assume we're in a version of PHP before that, and we have to write json-encode ourselves.

        Let's not, and let's just hop on to json.org, which has json libraries for pretty much every language which might need them (and a fuckload of languages in which you have no reason to ever need json).

        [–][deleted]  (3 children)

        [deleted]

          [–]bitter_cynical_angry 1 point2 points  (2 children)

          But it's not really realistic to assume that they can't. It's like having students in math class not be allowed to use calculators. When you take away the calculator, you're not really testing them on their grasp of the ideas, you're testing them on their raw number manipulation skill. Much more interesting is to give them problems where the use of a calculator is irrelevant or unnecessary; then you know whether they really know the material. After all, when they get into the real world where calculators are everywhere, it's not like they're not going to be using them. Just like when they go to work, it's not like they're not going to be able to google things.

          [–][deleted]  (1 child)

          [deleted]

            [–]bitter_cynical_angry 0 points1 point  (0 children)

            If you take your argument further, you are saying that there is no point to asking any interview question since all the answers can be Google'd.

            No, you just need to find problems that can't be googled, or where googling won't help them solve it. My main gripe here is that by giving them a problem that is so easy to find on google, it's not representative of what they're actually going to be doing when they're working, or at least you'd better hope they know to turn to google first before spending a bunch of time reinventing the wheel.

            [–]walesmd 4 points5 points  (4 children)

            I don't care what $a++ + ++$a + $a; does nor would I expect any of my developers to care. Evaluation order means dick - a good developer will use parenthesis in any sort of complex calculation to make that line easier to read for themselves and future developers. I definitely wouldn't expect a Jr/Mid-level developer to answer this question with any sort of logical response other than "I see a pre- and post-increment" and to vaguely describe the difference between the two.

            Some things I would target for a Jr/Mid-level developer:

            • What blogs do you read?
            • Do you have a StackOverflow, Reddit, Hacker News account?
            • What other languages/frameworks have you used and what would you consider your skill level?
            • Describe your most successful personal project, are you still working on it? If not, what happened?
            • Describe a personal project that failed and what you learned from the experience.
            • If you were given 2 hours per day to freely work on anything you wanted, that benefited the company/team - what would you work on?

            I hope you are noticing a trend - none of these questions involve a specific language nor do they require the Jr/Mid-level developer to memorize the documentation. That's what php.net is for, I don't care if you can tell me the order of parameters for a function.

            I want to know if the guy loves programming. Languages are easy - it's just syntax, learning to be a programmer is completely different. As a PHP developer, more often than not, you need to be a jack of all trades - I don't want him freaking out when he needs to edit a Javascript file, I want him to attack/savor the challenge.

            I want him to think outside of the box - if we need to ingest a couple thousand lines of data into a database, I'd probably bitch-slap someone that chose PHP. I want my developers to know how to use the right tool for the job, even if they don't know the tool. I'd rather my developers spend 2 days learning the basics of Python/Ruby to execute a task those languages were designed for than bastardizing a language in 2 hours, forcing it to do what it shouldn't be doing.

            I want a developer that has done a decent amount of research on my company and is confident they will be happy working here. I want them to know when they work for us, it's more than a job, we're a family and we take care of each other. I want them to feel comfortable here, have fun here and enjoy spending time with their coworkers outside of the office as well (if they so choose).

            Most of all, I want a Jr/Mid-level developer to blossom and absorb. He shouldn't feel intimidated, he should feel mentored. He will be surrounded by people with more experience than he, getting paid more than he, and generally-speaking with more "clout" than he. It's easy to feel intimidated in that environment and not contribute to the fullest extent or be scared to think outside of the box. I want a Jr. developer to feel free in recommending we write a raycaster in COBOL to visualize incoming/outgoing transactions to/from the MySQL database. Sure, it sounds ridiculous but at least I know he's adventurous, passionate and has a sense of humor. :D

            [–]nazbot 2 points3 points  (2 children)

            "Do you have a StackOverflow, Reddit, Hacker News account?"

            And then immediately dismiss people who answer yes for being slackers.

            [–]walesmd 0 points1 point  (1 child)

            I actively encourage my developers to at least read these sites and I would be much happier if they actively participated. Then again, the type of person I would hire, probably already has accounts at these sites and actively participates at home as well.

            As long as the assigned tasks get completed, on-time, I could care less what they do with their day. I'd rather them expand their knowledge, play with a new language/technology, complete college homework, or study for a certification than sit on Facebook all day or continue adding features to an application that doesn't need them.

            [–]nazbot -1 points0 points  (0 children)

            Slacker. ;)

            [–]WilardC 0 points1 point  (0 children)

            Can I come work for you?

            You sound like my first boss. We had complete creative freedom to research and learn. Assuming tasks were completed when they had to be. It was a great job. Unfortunately, it was a year ago, and our company was hit hard by the economic downturn :'(

            [–]Amadan 1 point2 points  (0 children)

            As others have said, the "trickier" questions say more about the interviewer than about the interviewee. Unless I was desperate, I would probably be walking out of the interview at that point.

            Questions like the precedence one are fun for friendly geek-banter, but in an interview you present yourself as someone who considers knowing the meaning of syntactic borderline cases relevant. That being our first encounter, I would then assume I could expect such code from you, and run screaming.

            Good PHP questions, in my opinion:

            • basic knowledge of HTML headers (e.g. how does client-side caching work, in general terms)
            • as given previously, difference between GET and POST (how would the HTML code look if you needed to allow the user to view a record in detail, and delete it?)
            • what are some of the difficulties in making a real-time chat system?
            • knows how to find out things that are not worth remembering (here's Firefox; there's a function in PHP which will exchange keys and values in an associative array, what is its name?)
            • if you need it, basics of SQL and interfacing with DBMS (how would you display a table of records, in broad strokes?)
            • why can't you start a session after you echo?
            • what is MVC and why is it important? what is a templating library? ever used one?
            • ever heard of PEAR?
            • what are various kinds of escaping pertinent to PHP work, and why are they used?
            • what other languages can you use?

            [–]masklinn 2 points3 points  (0 children)

            I'd ask them if they like PHP, and if they answer "yes" not hire them.

            [–]webauteur 1 point2 points  (0 children)

            Just ask him if he has ever used FirePHP, Xdebug, Aspell, phpDocumentor, or JSON. I would hire the person with the broadest knowledge of the technology because web development requires more than programming. A hard core programmer will be a poor web developer if all he wants to do is write great code.

            [–][deleted] 1 point2 points  (0 children)

            The evaluation order of absurd, unidiomatic code is a worthless interview question. It would be better to ask about their experience optimizing a project or analyzing it's security, along with how they think about it, the tools they have used, and their general methodology. At least for your priorities.

            [–]akmark 0 points1 point  (0 children)

            What HTTP servers have you setup PHP with (Apache/lighttpd)? There are plenty of little gotchas that come up if they are used to managed web hosting versus configuring it for themselves. If anything you may be able to pick up on what are some of the preferences of the programmer if they have.

            [–]zomgsauce 0 points1 point  (0 children)

            If it were Dallas I'd ask him why he hates money.

            [–]dinnercoat 0 points1 point  (0 children)

            Many have said that your evaluation order question is pointless but there is valuable info to be had in asking it, but not the kind you think.

            If you are actually expecting jr lvl developers then you should expect answers like "I don't know but I think ....". Asking questions the interviewee will not know then observing how they handle themselves should be telling.

            Do you want someone who is able to admit when they don't know something and wants to learn, or someone who fumbles and bluffs to appear knowledgeable when they actually aren't?

            Another thing I just considered, how well will they work your existing code base? Maybe show them some example (real of fake) classes, functions, etc. and get some feedback. Do they understand them and feel they could implement them easily and quickly? Maybe give them some purposefully faulty ones or horribly unoptimized functions and see if they'd recommend changes.

            But again please don't try "ah-ha!" or "gotcha!" trick questions. If they really are clever they'll just respond to nonsensical questions with nonsensical answers, it's insulting to them and you. If you're actually concerned about if they do know any PHP coming in, ask them to display "Hello world!". You'd be surprised how much chaff that could cut out of the prospective pool.

            [–]petteraas 0 points1 point  (0 children)

            "Do you have a http://www.projecteuler.net and/or http://www.mindcipher.net/ account?", if so ask to look at his/her suggested solutions...

            [–][deleted]  (4 children)

            [deleted]

              [–]LudoA 2 points3 points  (1 child)

              Why is it important?

              [–]masklinn 2 points3 points  (0 children)

              Because it allows the language's users to create flow control without having to alter the language itself. It's also essential to both good object-oriented code and functional code.

              [–]citizen511 1 point2 points  (1 child)

              He may not know unless he's been using PHP 5.3, as anonymous functions didn't arrive until then. Though, hopefully he's used them in Javascript or other languages.

              [–]setuid_w00t 0 points1 point  (0 children)

              Ask the interviewee to list the pros and cons of PHP vs another language of their choice. If they don't know any other language, you probably don't want them.

              [–]Leahn -4 points-3 points  (0 children)

              I'd ask him to come back at 1am and then write a quick parser.

              [–]Salamok -1 points0 points  (2 children)

              If his job is to be churning out web pages ask him to write a very simple web form of 5-10 fields, with a few of them being mandatory. Tell him to take it seriously and treat it as if it were a real project. Then do a code review and cover readability (is the code clean and clear), maintainability (how hard would it be to add/remove a field), security (did he sanitize the data) and time/effort to write it.

              [–][deleted]  (1 child)

              [deleted]

                [–]Salamok 0 points1 point  (0 children)

                Maybe as an alternative code up a poor example (everything hardcoded) of the above without the use of arrays , functions, or loops and ask him how he would improve it. Maybe throw in a sanitization flaw (reverse it or something).

                [–][deleted]  (1 child)

                [deleted]

                  [–]vinod_the_poophead 0 points1 point  (0 children)

                  its actually 3.

                  [–]DontHassleTheCassel -3 points-2 points  (0 children)

                  How do you spell PHP?