Inegality Comparisons

The loose comparisons (which includes =) between integers and strings have changed in PHP 8.0. Until now, a string was strictly superior to any integer, but was superior or egal to any integer.

Since PHP 8.0, strings are considered to be higher than integers. The comparison is consistent between the strict and inclusive comparison.

This also applies to float.

PHP code

<?php

var_dump(0 > 'a');
var_dump(0 >= 'a');

var_dump(0 < 'a');
var_dump(0 <= 'a');

?>

Before

bool(false)
bool(true)
bool(false)
bool(true)

After

bool(false)
bool(false)
bool(true)
bool(true)

PHP version change

This behavior changed in 8.0