Recently, we ran into a disaster and forced to port our php web application from PHP version 5.2.6-1 + lenny16 to PHP version 5.3.3-7 + squeeze15 and found an apparent significant difference.
In our application, there were cases when we incorrectly called the array index using the object syntax:
echo $array->index;
However, 5.2.6 seemed to forgive it and relate to it as if $ array ['index'] was written.
In further testing, what 5.2.6 specifically does is inconsistent with 5.3.3 as to whether $ array-> index is empty ();
Here is the test code that I ran on both servers:
<?php echo phpversion() . '<br>'; $array = array( 'x' => 1, 'y' => 2 ); if (!empty($array->x)) { echo "not empty"; } else { echo "empty"; } ?>
Here are two different options:
5.2.6-1+lenny16 not empty 5.3.3-7+squeeze15 empty
Naturally, there are several outbreaks of broken functionality, because we were never warned about these errors during development. Is there a way that we can configure php 5.3 to resolve this incorrect syntax while we take a bit more time to find all of its incorrect instances?
I don't think this is a configuration problem, right? Has anything changed in the way empty () works between versions?
source share