๐ฏ By the end of this lesson you canโฆ
- Use arithmetic and assignment operators
- Compare strictly with = and !
- Use ??, ?: and <=>
๐ PHP
operators.php
๐ Tap a line to explain it
1<?php2echo 17 % 5, " ", 2 ** 8, " ", intdiv(17, 5), "\n";3$score = 10;4$score += 5;5$score++;6echo $score, "\n";7var_dump(5 == "5", 5 === "5");8$user = null;9echo $user ?? "Guest", "\n";10echo 3 <=> 7, " ", 7 <=> 7, " ", 9 <=> 7, "\n";11var_dump($score > 10 && $score < 20);
๐ฎ What will this display?
What does this print?
1<?php2$a = null;3$b = 0;4echo ($a ?? "A") . ($b ?? "B");
๐ Key takeaways
%remainder,**power,intdiv()whole division.- Use
===(value AND type) instead of==. $x ?? "default"uses a default when $x is missing or null.
Finished reading & practising?
Saved in this browser. Create a free account to keep it forever.