Last Updated: 03 Oct 2025
|
This is an old revision of the document!
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-unitor 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
GETrequest and aPOSTrequest? 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()andpreg_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()andurldecode(), and why do you need them? What aboutrawurlencode()andrawurldecode()? 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…)
OO PHP
- What's the difference between
public,privateandprotected? - What's the difference between
$this→myFunction()andself::myFunction()? - When is
_destruct()called? - How do you catch an exception? Explain exactly how a
try-catchblock works. - What does the keyword
finalmean? - 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 toserialize()andunserialize()) - How about
_get()and_set()? What are some (dis)advantages to using_get()&_set()over conventional getter and setter functions?
Discussion