Module 2 – PHP Fundamentals
Lesson
Operators
Arithmetic, comparison, and logical
Arithmetic: +, -, *, /, % (modulo). Assignment: +=, -=. Comparison: ==, ===, !=, <, >. Logic: &&, ||, !. Null coalescing ?? and spaceship <=> simplify modern code. The . operator concatenates strings.
Precedence
Parentheses change the order of evaluation. Study the precedence table in the PHP documentation when writing complex expressions.
<?php
$a = 10; $b = 3;
echo $a % $b;
$ime = $_GET["ime"] ?? "Gost";
echo ($a <=> $b);Example variation
Extend the lesson example: add another variable, change the loop boundary or branching, and observe the output. Deliberately introduce an error (e.g. an undefined variable) to see the PHP message – then fix it.
