[Typo3-dev] PHP5

Martin T. Kutschker Martin.T.Kutschker at blackbox.net
Wed Apr 21 09:59:22 CEST 2004


Christian Jul Jensen wrote:
> 
> That actually works, the only thing is, you still don't know if it's
> an array, but using that you could check it in only two calls:
> 
> if(isset($my_array['some']['special']['value']['that']['i']['need']))
>    &&
>    is_array($my_array['some']['special']['value']['that']['i']['need']))
> 
> instead of the horrible thing I posted earlier.
> 
> Still I think that it's a really weird behaviour, I think it must be a
> side-effect of something else. Ie. it doesn't issue a fatal error if
> you execute.
> 
> echo
> is_array($my_array['some']['special']['value']['that']['i']['need']);

Conclusion: to resolve any warning/error issues use isset() on scalars 
and is_array() on  arrays. Don't test for the existence of a value by 
mere referncing to it. A coding practice I have seen in other PHP 
projects anyway.

Implementing this in Typo3 will be a lot of work, but there are 
benefits. When looking for possible programming errors one might enable 
the PHP warning output without wading through many lines of this type.

BTW, does $arr[pseudo_const] now issue an error? In 3.5 there are places 
(at least in the distributed extensions) where this syntax is used 
insted of $arr['pseudo_const'].

Masi





More information about the TYPO3-dev mailing list