>When I use foreach on a uninitialized array I get the following warning:
>
>Warning:  Invalid argument supplied for foreach() in 
>/www/htdocs/jc/cart/add_item.php on line 21
>
>I would expect foreach to treat an unitialized variable as an empty 
>array and hence do nothing. Is this the expected behaviour?

It is the expected behaviour.

If you absolute *MUST* refuse to initialize the array (BAD IDEA!) you could
set error_reporting to (E_ALL - E_NOTICE) in php.ini or using
http://php.net/error_reporting

You would be *MUCH* better off listening to those warnings and fixing your
code.

*MUCH* better off.

-- 
Like Music?  http://l-i-e.com/artists.htm


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to