12 questions to validate Databases & OOP: PDO and prepared statements, OOP, namespaces and Composer, XSS/CSRF/hashing security.
Answer everything, then click Check: your score and explanations will appear.
3.1 · Recall
1. A PDO prepared statement is first and foremost…
Code and data separated: the database treats values as pure data.
3.1 · Application
2. Riad looks up a client by entered email. He writes…
Named placeholder + execute(): no concatenation, no injection.
3.1 · Arbitration
3. A colleague concatenates the input “just for testing”. Correct call?
Test code ends up in production; injection is born from concatenation.
3.2 · Recall
4. Encapsulation recommends…
The object protects its state: the invalid is refused at the source.
3.2 · Application
5. Riad creates a specialized admin from Utilisateur. He writes…
Extends = reuse and specialize (“is a” relationship).
3.2 · Application
6. Riad wants a Notifiable contract for several classes. He writes…
The interface contracts: classes commit, code decouples.
3.3 · Recall
7. Namespaces are first for…
Two Users coexist in different spaces (use to import).
3.3 · Application
8. Riad installs a sending library via Composer. He writes…
Composer installs, resolves and generates the PSR-4 autoloader.
3.3 · Arbitration
9. Should vendor/ be versioned in Git? Correct call?
Vendor/ is regenerable; the lock guarantees reproducibility.
3.4 · Recall
10. Against XSS on output, the reflex is…
Escaped, the injected script becomes harmless text.
3.4 · Application
11. Riad stores a password at registration. He writes…
Hashed at storage, verified by password_verify(): never plain text.
3.4 · Arbitration
12. Before going live, the shop displays raw pseudos and has no CSRF token. Correct call?
XSS and CSRF close before opening: each output has its defence.
What's next?
Score ≥ 80%: move to Level 4 — MVC, Laravel/Symfony and REST APIs (building on sound, safe foundations).
Score 50-79%: revisit the failed sections (prepared in 3.1, encapsulation in 3.2, PSR-4/Composer in 3.3, security quartet in 3.4) then retake the test.
Score < 50%: reread level 2 (forms, sessions, inclusions) then replay each 48h challenge in order.