← 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
Ready to go further?

These free tutorials are a preview, our Backend Development cohort covers it in depth, with a real project and a cohort alongside you. Active

Enroll in Backend Development
Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account