Job preparationPHP
PHP interview questions and answers

Variables, arrays, sessions, OOP, PDO and file uploads — the PHP questions for web developer roles.
PHP is still the most in-demand skill for web development jobs here, particularly alongside Laravel.
The questions below run from the basics of the language through to databases and security — the order a board tends to walk you in.
The questions
What is PHP and what is it used for?
What to coverPHP (Hypertext Preprocessor) is a server-side scripting language used to build dynamic web pages.
How is a variable declared in PHP and what are the rules?
What to coverA variable starts with a $ sign, must have a name beginning with a letter or an underscore, and is case-sensitive.
What data types does PHP have by default?
What to coverInteger, float, string, boolean, array, object, NULL and resource.
How are cookies and sessions managed in PHP?
What to coverCookies store data on the client; sessions store it on the server. setcookie() sets a cookie and session_start() begins a session.
What is an array in PHP and what kinds are there?
What to coverPHP has three: indexed arrays, associative arrays and multidimensional arrays.
How is form data handled in PHP?
What to coverThrough the $_GET and $_POST superglobals.
What are include and require in PHP, and what is the difference?
What to coverIf the file is missing, include raises a warning and the script continues; require raises a fatal error and the script stops.
What is object-oriented programming in PHP and what are its four main features?
What to coverClasses and objects, inheritance, polymorphism and encapsulation.
What are constructors and destructors in PHP and what do they do?
What to coverA constructor is a special method run when an object is initialised. A destructor runs cleanup just before an object is destroyed.
What is the difference between PDO and mysqli in PHP?
What to coverPDO is a database abstraction layer offering one interface across several databases; mysqli is specific to MySQL.
How do you upload a file in PHP, and what security measures are needed?
What to coverUploads come through the $_FILES superglobal. Security means checking the file type, limiting the file size, and sanitising the file name.
How do you encode and decode JSON data in PHP?
What to coverjson_encode() to encode and json_decode() to decode.
Tips for this round
- include versus require is a small question that comes up nearly every time. Have a one-line answer ready.
- On file uploads, bring up security yourself, before you are asked. It earns separate credit.
- PDO or mysqli: being able to argue for PDO makes a good impression.