Recursive Comparison Of Arrays

Until PHP 8.4, recursive arrays should not be compared one another, as the engine might ends in an infinite loop.

In PHP 8.4, it is now a catchable Error.

PHP code

<?php

$array = [1,2,3, &$array];
$array2 = [1,2,3, &$array2];

var_dump($array == $array2);

?>

Before

PHP Fatal error:  Nesting level too deep - recursive dependency?

Fatal error: Nesting level too deep - recursive dependency?

After

PHP Fatal error:  Uncaught Error: Nesting level too deep - recursive dependency?

Fatal error: Uncaught Error: Nesting level too deep - recursive dependency?

PHP version change

This behavior changed in 8.4

Error Messages