Re: 5.4 regression: non-existent sub-sub keys now have values
| From: | Lester Caine | Date: | Wed, 23 Nov 2011 10:51:12 +0000 |
| Subject: | Re: 5.4 regression: non-existent sub-sub keys now have values | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-56498@lists.php.net to get a copy of this message | ||
Ferenc Kovacs wrote:
On Wed, Nov 23, 2011 at 10:51 AM, Lester Caine <lester@lsces.co.uk <mailto:lester@lsces.co.uk>> wrote:THAT was what was confusing things ... but I wonder what code was failing in PEAR? The code here was looking for an array element to check that the ARRAY had been populated, but the holding element was just a simple string rather than an empty array.Ferenc Kovacs wrote:some clarification: in the test script, Daniel declared $arr as: $arr = array('exists' => 'foo'); so when he tests $arr['exists']['non_existent'] PHP will see that $arr['exists'] is a string, and it will convert the 'non_existent' index to int(0) and that will return the same as $arr['exists'][0]: 'f' If he would have defined $arr['exists'] as an array, then the code would work as he expected, empty would returned true for $arr['exists']['non_existent']The bit I am missing here is the statement that $arr = array ... has NOT created an array with an element ['exists']yes it did, but ['exists'] wasn't defined as an array, but as a string.
... I suspect that this is perhaps where the code *I* am looking at is
breaking down ... how SHOULD you define the array so that it is an array? So
that $family = array ( 'fam1' => 'JONES' ); is the base for the JONES family
rather than simply a string. All of this USED to be simple, but it seems to
be getting so cryptic that this is what is causing the trouble :(
The legacy code methods may be wrong, but a lot of this code originates in PHP4 days, so when things do break what is needed is a clean upgrade guide which may help to isolate the bugs when they appear?
I think you just need a coffee. No just a version of PHP where I'm not firefighting changes but getting back to actually producing new code :( I can either test 5.4 or work ... I don't have time for both ...-- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php