ID: 6118 Comment by: slight_ at hotmail dot com Reported By: ronen at greyzone dot com Status: Open Bug Type: Feature/Change Request Operating System: Redhat Linux 6.2 PHP Version: 4.0.1pl2 New Comment:
I'd just like to add a vote for this as a new feature. I have countless foreach blocks wrapped in if( is_array( $x ) ){} where the only reason to check is to avoid raising a warning. Previous Comments: ------------------------------------------------------------------------ [2000-08-12 03:12:31] [EMAIL PROTECTED] Well, it's still a valid feature request. Why to be overzealous to close it, maybe somewhere in PHP 6.5 we decide to implement it? :) ------------------------------------------------------------------------ [2000-08-12 03:01:58] [EMAIL PROTECTED] Actually its not that... foreach is a statement, you can't suppress warnings for statements. ------------------------------------------------------------------------ [2000-08-12 02:40:05] [EMAIL PROTECTED] At the moment it seems that parse errors can not be suppressed, but I think it is not possible to do it, and it is absolutely not useful. >From the manual: "All PHP expressions can also be called with the "@" prefix, which turns off error reporting for that particular expression" But if PHP can see there is an expression (because of an parse error), there is no way to disable warnings from that statement. ------------------------------------------------------------------------ [2000-08-12 02:29:39] ronen at greyzone dot com @foreach($items as $key => $val) {} does not work: <? $test[123]="one hundred twenty three"; $test[13]="thirteen"; $test[11]="eleven"; // try to supress warnings on foreach @foreach($test as $key => $value) { echo "TEST[$key]=$value<br>"; } /***** THE OUTPUT IS Parse error: parse error in /home/httpd/brocadedocs/ronen/secure/testtest.html on line 10 ****/ ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=6118&edit=1