PHP: Testing whether three variables are equal

Matty picture Matty · Jan 16, 2011 · Viewed 29k times · Source

I've never come across this before, but how would you test whether three variables are the same? The following, obviously doesn't work but I can't think of an elegant (and correct) way to write the following:

if ($select_above_average === $select_average === $select_below_average) { }

Answer

Marc B picture Marc B · Jan 16, 2011
if ((a == b) && (b == c)) {
   ... they're all equal ...
}

by the transitive relation