Last Updated: 21 Nov 2020


Author: (external edit)

PHP Interview Questions

Also see the PHP/MySQL Questions and General CS Questions.

  • What are some of the big differences between PHP4 and PHP5?
  • What is PEAR?
  • Is PHP a typed language? Why or why not?
  • Does PHP pass data by value or reference? What's the difference?
  • Outline the process for connecting to a MySQL database, walking through connecting, querying data, and getting the return value. What are some of the things that you need to watch out for?
  • Have you ever done any unit testing in PHP with php-unit or another package? Tell me about how it went, and some of the pros & cons.
  • Have you used any PHP frameworks (Zend, PEAR, etc.)? Thoughts?
  • What's a GET request and a POST request? What are the high-level differences between each?
  • What do you have to do to be able to begin a PHP file with a short tag (e.g. <? instead of <?php)?
  • What's the difference between ereg_match() and preg_match()?
  • When do you want to use double quotes ( $str = “foo” ) vs single quotes ( $str = 'foo' ) to initialize strings? What is the difference?
  • What are urlencode() and urldecode(), and why do you need them? What about rawurlencode() and rawurldecode()? What's the difference?
  • Can you describe what happens, from a technical level, when a web browser brings up a web page? (e.g. there's a DNS lookup, then an HTTP request to the remote web server, then…)


  • What's the difference between public, private and protected?
  • What's the difference between $this→myFunction() and self::myFunction() ?
  • When is _destruct() called?
  • How do you catch an exception? Explain exactly how a try-catch block works.
  • What does the keyword final mean?
  • How do you make an abstract class in PHP? What does that do?
  • Talk about the difference between abstract classes and interfaces in PHP. In particular, discuss the fact that an interface only specifies a 'contract' of functions you have to implement, and can't specify implementation details at all, but a class an implement more than one interface. An abstract class also specifies a contract, and does allow you to specify implementation in the class, but PHP doesn't let you extend more than one class at once.
  • Have you used any of the magic methods?
    • What do the _sleep() and _wakeup() functions do? (Hint: in reference to serialize() and unserialize())
    • How about _get() and _set()? What are some (dis)advantages to using _get() & _set() over conventional getter and setter functions?


Enter your comment. Wiki syntax is allowed: