[Typo3-dev] PHP5

Martin T. Kutschker Martin.T.Kutschker at blackbox.net
Wed Apr 21 02:18:46 CEST 2004


Christian Jul Jensen wrote:
> 
> ---example
> 
> $a = 'I honestly thought this was an array';
> echo $a[3];
> echo $a[3]['someindex'];
> 
> ---
> in PHP4 this will return an h (the third letter in the string), and
> ignore the line third line.
> 
> PHP5 returns an h, and a fatal error.

Note that it should reade $a{4} anyway (square brackets for string 
indexing is deprecated).

> Althoguh this makes pretty much sense, it is a problem because you
> might also get a fatal error in the following case, even tough you
> actually check for the existence of the array that you need.
> 
> ---example
> 
> $my_array = $some_weird_function_that_returns_a_multidim_array();
> if(is_array($my_array['some']['special']['value']['that']['i']['need']))
> {
>         apply_logic();
> }
> 
> ---
> 
> in PHP5, in order not to risk a fatal error, this would have to be:

What happens when you do this?

$my_array = $some_weird_function_that_returns_a_multidim_array();
if(isset($my_array['some']['special']['value']['that']['i']['need']))
{
          apply_logic();
}

Masi





More information about the TYPO3-dev mailing list