12 questions to validate PHP language basics: variables, conditions, loops, functions, arrays and strings.
Answer everything, then click Check: your score and explanations will appear.
1.1 · Recall
1. Which comparison to prefer in modern PHP, and why?
=== compares without conversion: predictable, and safe for sensitive values.
1.1 · Application
2. Riad joins "Total: " and the amount $total. Correct writing?
In PHP strings are joined with the DOT; + computes instead of joining.
1.2 · Recall
3. Which value does PHP consider "falsy" in a tricky way?
'0' is falsy: if ($x) treats it as missing — test explicitly.
1.2 · Application
4. Riad wants the requested page, or 1 if the parameter is missing — without wiping out a legitimate 0. Writing?
?? triggers only on null/absence; the explicit 0 stays respected.
1.2 · Application
5. Riad's rate switch applies two rates at once. Likely cause?
Without break, the switch continues into the next case (fall-through).
1.3 · Application
6. Riad displays each service of a $prestations array. Recommended loop?
foreach iterates with no manual index: simple, safe, no off-by-one error.
1.3 · Arbitration
7. Catalogue of 200 services: Riad looks for one name and stops as soon as he finds it. Call?
break avoids useless work; htmlspecialchars stays mandatory on display.
1.4 · Recall
8. A variable defined INSIDE a PHP function is…
Wanted isolation: everything enters via parameters, everything exits via return.
1.4 · Application
9. Riad writes prixTTC(float $ht, float $taux = 0.19): float. What does he gain?
Typing documents, catches wrong types and helps tooling.
1.5 · Application
10. Riad stores one service with its named name and rate. Adapted structure?
Named data = associative: $prestation['tarif'] says what it holds.
1.5 · Arbitration
11. An accented title "Référencement" is measured at 14 by strlen instead of 13. Call?
In UTF-8 an accented character weighs 2 bytes: mb_* counts characters right.
1.1 · Arbitration
12. Riad compares a reset token with == and a forged token passes. Call?
== with conversion can equalise different values: historic vulnerability — strict mandatory.
What's next?
Score ≥ 80%: move on to V3 Level 2 (forms, sessions, files and dates — server-side PHP that receives and processes data).
Score between 50% and 80%: revisit the failed sections (=== in 1.1, falsy in 1.2, foreach in 1.3, scope in 1.4, arrays in 1.5), re-read the explanations above, then retake the test.
Score < 50%: restart the level running each template locally — the basics (variables, conditions, loops) carry everything else.