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
==vs===— loose vs strict comparison (and type juggling).- Data types; what are superglobals ($_GET, $_POST, $_SESSION)?
- include vs require (and the _once variants).
- What does
echovsprintdo; isset vs empty. - Variable scope and the
globalkeyword.
Sessions, cookies & the web model
- Sessions vs cookies — the key difference and when to use each.
- How does PHP handle a request (stateless, per-request execution)?
- GET vs POST.
- How do you connect to a database (PDO vs mysqli)?
OOP & security
- OOP in PHP — classes, interfaces, traits (our OOPs guide).
- What are traits and when do you use them?
- Security — SQL injection (use prepared statements), XSS, CSRF.
- How do you hash passwords (password_hash)?
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.