# Type-juggling and (strict) greater/lesser-than comparisons in PHP?

PHP is famous for its type-juggling. I must admit it puzzles me, and I'm having a hard time to find out basic logical/fundamental things in comparisons. For example: If $a >$b is true and $b >$c is true, must it mean that $a >$c is *always* true too? Following basic logic, I would say *yes* however I'm that puzzled I do not really trust PHP in this. Maybe someone can provide an example where this is not the case? Also I'm wondering with the strict lesser-than and strict greater-than operators (as their meaning is described as strictly which I only knew in the past from the equality comparisons) if it makes any difference if left and right operands are swapped with strictly unequal values: # Precondition: if ($a ===$b) { throw new Exception( 'Both are strictly equal - can not compare strictly for greater or smaller' ); } ($a >$b) !== ($b >$a) For most of all type comparison combinations these [greater / lesser comparison operators](http://php.net/language.operators.comparison) are not documented, so reading the manual was not really helpful in this case.

## 1 Expert Answer

By:

Stefan R. answered • 02/06/20

Tutor
5.0 (625)

Senior PHP developer with 10+ years of experience

## Still looking for help? Get the right answer, fast.

Get a free answer to a quick problem.
Most questions answered within 4 hours.

#### OR

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.