PHP Hard Interview Questions

Questions to ask a PHP Developer

PHP engineers are often required to have a knowledge of the full web stack: starting with the ability to write optimized SQL queries, and wrapping up with a good understanding of HTML/CSS. When interviewing a PHP developer, make sure that you think through your requirements and ask good questions for all of them.

Here's a suggestion for a good menu of PHP interview questions:

  1. Start off with some basic SQL such as SQL Skills: Joins, Averages and Sums
  2. Include at least one simple coding task such as Separate a list of integers or Find the missing number
  3. Explore their ability to come up with an overall system design and data model with a flexible question like Design a restaurant reservation system or Design a card game system
  4. Ensure that they have a solid understanding of the basic building blocks of the web by asking about HTTP GET and POST or What are HTTP cookies?
  5. Wrap up with some CSS questions like Explore the HTML display and position attributes or CSS rule-set basics

Suppose you have a web form that allows users to upload JPG, GIF or PNG images. Before you store the images in your system, you want to convert them all to the JPG format. Design an image converter API. Sketch out all classes and interfaces that are involved.

Note: the actual code necessary to convert a JPG image to a GIF image is not the point. Just place a comment at the appropriate location where the actual conversion should occur.

Suppose you have an array of 99 numbers. The array contains the digits 1 to 100 with one digit missing. Describe four different algorithms to compute the missing number. Two of these should optimize for low storage and two of these should optimize for fast processing.

Define the following object oriented concepts:

  • Class, object (and the difference between the two)
  • Instantiation
  • Method (as opposed to, say, a C function)
  • Static methods and classes
  • Destructor/finalizer
  • Inheritance
  • Encapsulation
  • Multiple inheritance (and give an example)
  • Abstract class
  • Interface/protocol (and different from abstract class)
  • Method overriding
  • Method overloading (and difference from overriding)
  • Polymorphism (without resorting to examples)
  • Method visibility (e.g. public/private/other)

Explain big o notation and how it is useful in computer science to classify algorithms.

  • What order is a hash table lookup?
  • What order is determining if a number is even or odd?
  • What order is finding an item in an unsorted list?
  • What order is a binary search?