Lesson content
Read, practise, then check your understanding
Arithmetic uses + - * / % **; strings join with .. Prefer strict === and !==; == coerces. The spaceship operator <=> returns ordering, and logical operators short-circuit.
Practical example
<?php
$display = $input['name'] ?? 'Anonymous';
$allowed = $authenticated && $role === 'editor';
$total += $price * $quantity;
$label = $first . ' ' . $last;
?? handles unset/null array entries, while ?-> stops member access on null. Textual and and or have unexpectedly low precedence. Parenthesize mixed logic and do not use error suppression @ as control flow.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.