← PHP tutorial

PHP

Operators

Arithmetic (+ - * /) and logical (&& || !) operators work much like other C-family languages.

Example: loose vs. strict comparison

<?php
  $score = 85;
  $passed = $score >= 50 && $score <= 100;
  echo $passed ? "true" : "false";
?>
true

PHP offers both == (loose — allows type conversion before comparing, similar to JavaScript's ==) and === (strict — compares type and value together, no conversion). As with JavaScript, prefer === by default; it avoids surprising results like 0 == "abc" historically returning true in some PHP versions.

Example
<?php
  $score = 85;
  $passed = $score >= 50 && $score <= 100;
  echo $passed ? "true" : "false";
?>
Output
true