← Back to blog

PHP interview questions and answers

PHP interview questions and answers — cover from Greenroom, the AI mock interviewer

PHP still powers a huge share of the web (WordPress, Laravel, legacy systems), and its interviews test core language behavior, OOP, the request model (sessions and cookies), and web security. Here are the PHP interview questions that actually get asked, with answers. (See also our SQL and backend guides.)

Core PHP

Sessions, cookies & the web model

PHP interview topics — data types, sessions, OOP, superglobals, security
PHP rounds test core behavior, sessions vs cookies, and web security basics.

OOP & security

The core truth: PHP interviews reward knowing the language's quirks (type juggling, == vs ===), the stateless request model, and security basics — using prepared statements and proper password hashing signals someone who writes safe PHP, not just working PHP.

How to prepare

PHP rounds probe behavior and security verbally. Practise explaining sessions vs cookies and SQL-injection defense out loud. Greenroom runs spoken technical interviews that follow up on your reasoning. Pair it with our SQL and backend guides.

Frequently asked questions

What are the most common PHP interview questions?

Common PHP questions cover == vs === and type juggling, data types and superglobals, include vs require, isset vs empty, variable scope, sessions vs cookies, the stateless per-request model, GET vs POST, database access with PDO vs mysqli, OOP (classes, interfaces, traits), and security topics like SQL injection, XSS, CSRF and password hashing.

What is the difference between sessions and cookies in PHP?

Cookies are small pieces of data stored on the client's browser and sent with each request, suitable for non-sensitive data like preferences. Sessions store data on the server, with only a session ID sent to the client via a cookie, making them more secure for sensitive data like login state. Cookies persist per their expiry; sessions typically last until the browser closes or the session times out.

What is the difference between == and === in PHP?

== is loose comparison: it compares values after type juggling, so '5' == 5 is true. === is strict comparison: it checks both value and type, so '5' === 5 is false because one is a string and the other an integer. Strict comparison avoids subtle bugs from PHP's automatic type conversion, so === is generally preferred.

How should I prepare for a PHP interview?

Focus on the language's quirks (type juggling, == vs ===), the stateless request model, sessions vs cookies, OOP including traits, and especially security — prepared statements against SQL injection and proper password hashing. Practise explaining the request model and security defenses out loud with a voice-based mock interview that follows up, since these rounds probe behavior and safe-coding judgment.

PHP rounds reward knowing the quirks and security, out loud. Greenroom runs spoken technical interviews that follow up on your reasoning. Free to start.