PHP interviews cover language semantics, OOP, Laravel or Symfony, MySQL, and web security basics. Below are the most common questions with model answers. Junior: core theory, definitions, and simple practical cases.
1
What is the difference between `==` and `===`?
Answer
== compares after type juggling, === compares value and type. PHP 8 made the juggling far saner — 0 == "foo" is now false — but the rule stands: use === unless you have a reason not to, because the comparison table is something nobody should have to remember.
2
What is the difference between an interface, an abstract class and a trait?
Answer
An interface declares what a class can do and carries no implementation. An abstract class can hold state and partial implementation, and a class extends only one. A trait is code injected into a class — PHP's answer to not having multiple inheritance. Traits are for shared implementation, interfaces for shared contract.
3
What do `public`, `protected` and `private` actually restrict?
Answer
public is reachable anywhere, protected from the class and its subclasses, private only from the declaring class. private is stricter than people expect — a subclass cannot see it. Default to private and widen when something outside genuinely needs access.
4
What is the difference between `include` and `require`?
Answer
Both pull in a file; require raises a fatal error if it is missing, include only a warning and carries on. The _once variants skip a file already loaded. In modern code you meet these rarely, because Composer's autoloader resolves classes by namespace and you never write the path.
5
What is Composer and what is `composer.lock` for?
Answer
Composer resolves and installs dependencies. composer.json says what you want, composer.lock records exactly what was resolved — which is why the lock file is committed and why composer install on the server reproduces the same tree rather than picking newer versions.
6
What is type juggling and where does it still bite?
Answer
PHP converting types to compare or operate on them. It still bites when a string from a form arrives where a number was expected, and in loose comparisons inside in_array or switch, which use == by default. Declaring strict_types=1 at the top of a file turns the quiet coercion into an error.
7
What are the superglobals and why should you not read them directly?
Answer
$_GET, $_POST, $_SERVER, $_SESSION and the rest hold request data. Reading them directly spreads unvalidated input through the code and makes anything that touches them untestable, since there is no request to construct. A framework's request object wraps them, which is why you use it.
🦎
Reading answers is not enough
In a real interview you speak under pressure. Cam asks these same questions, scores every answer, and shows exactly what to fix.
Practice a Junior PHP Backend interview →Free · 3 interviews per month