Scream!
Trackbacks
PHP-Extension Scream
Die PHP-Extension Scream deaktiviert den @-Operator. Das ist nützlich, um ein Script besser debuggen zu können. Manche Leute kennen wohl nicht die Funktion error_reporting und dekorieren deshalb ihr Script massenhaft mit dem Klammeraffen...
Die PHP-Extension Scream deaktiviert den @-Operator. Das ist nützlich, um ein Script besser debuggen zu können. Manche Leute kennen wohl nicht die Funktion error_reporting und dekorieren deshalb ihr Script massenhaft mit dem Klammeraffen...
Weblog: Mr. Foo
Tracked: Feb 27, 10:18
Tracked: Feb 27, 10:18
Friday, February 27. 2009 at 00:20 (Link) (Reply)
Friday, February 27. 2009 at 08:12 (Link) (Reply)
Friday, February 27. 2009 at 08:38 (Link) (Reply)
for example:
[geshi lang=php]$id=(int)@$_REQUEST['id'];[/lang]
where you want an id from GET or POST, or 0 if it's not available.
That, instead of the more verbose
[geshi lang=php]$id=(isset($_REQUEST['id'])?(int)$_REQUEST['id']:0);[/lang]
Friday, February 27. 2009 at 13:18 (Link) (Reply)
I wouldn't use this extension in production code anyway and your approach #1 doesn't look very "expedient" - more unreadable and not "working as intended". Your approach #2 is much cleaner and easily readable anyway.
Friday, February 27. 2009 at 13:24 (Link) (Reply)
sed -i -e 's/@//g' `find . | grep php`
(of course @ should be a more complex regex)?
Friday, February 27. 2009 at 13:45 (Link) (Reply)
Oh and there are valid reasons for the @ - when accessing external resources and doing error handling afterwards. Something along these lines of $fp = @fopen('http://...', 'r'); if (!$fp) { handle_error_nicely(); } - There I won't like my error log having all these errors due to temporary net problems...
So I see this clearly as debugging help for bad code.
Tuesday, March 3. 2009 at 02:03 (Link) (Reply)
you look for something cleaner and more and easily readable.
why you didn't try
$old_error_reporting_value = error_reporting(0);
$fp = @fopen('http://...', 'r'); if (!$fp) { handle_error_nicely(); }
error_reporting($old_error_reporting_value);
???
Tuesday, March 3. 2009 at 02:06 (Link) (Reply)
like this:
$old_error_reporting_value = error_reporting(0);
$fp = fopen('http://...', 'r'); if (!$fp) { handle_error_nicely(); }
error_reporting($old_error_reporting_value);
Tuesday, March 3. 2009 at 09:13 (Link) (Reply)