Skip to content
AgileLogics
4 min read

Operators

Prerequisites: Type juggling & casting

PHP supports the usual arithmetic (+ - * / % **), comparison (== != > < >= <=), and logical (&& || !) operators.

Two comparison operators are worth calling out specifically:

0 == "0"   // true  — loose comparison, converts types first
0 === "0"  // false — strict comparison, checks type and value

Common mistakes

  • Using ==/!= out of habit — prefer ===/!== in almost all cases. Loose comparison's type coercion is a common source of subtle bugs.

Practice

Write a strict comparison that checks whether $score (an int) equals 100.

Show solution
$score === 100