---
title: PHP Interview Questions & Answers (2026): Core, OOP & Sessions
description: The PHP interview questions that get asked in 2026 — data types, sessions vs cookies, OOP, == vs ===, superglobals and security — with clear answers and what each tests.
url: https://usegreenroom.app/blog/php-interview-questions
last_updated: 2026-06-20
---

← Back to blog

Technical

# PHP interview questions and answers

June 20, 2026 · 9 min read

![PHP interview questions and answers — cover from Greenroom, the AI mock interviewer](/assets/blog/php-interview-questions-hero.webp)

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 `echo` vs `print` do; isset vs empty.
- Variable scope and the `global` keyword.

## 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)?

![PHP interview topics — data types, sessions, OOP, superglobals, security](/assets/blog/pool-structured-screen.webp)

PHP rounds test core behavior, sessions vs cookies, and web security basics.

## 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)?

**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.