Re: suppressing division by zero errors

From: Date: Thu, 31 Jan 2002 23:10:34 +0000
Subject: Re: suppressing division by zero errors
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83027@lists.php.net to get a copy of this message
On Thu, 2002-01-31 at 15:00, Martin Towell wrote: > Is there a way to suppress division by zero errors? > > echo 5/0; // this give a warning - obviously!! > > @echo 5/0; // this gives a parse error > > echo @5/0; // this still comes up with a warning > > unless I turn error_reporting off before and turn it back on afterwards, but > I don't want to do that unless I REALLY have to > > Martin The @ operator will work on the following expression in this case. In the last one above, you're suppressing the error from the expression '5', since the @ binds more tightly than the / (i.e. @ has a higher precedence). So you need to force precedence, which in PHP is done with parentheses: echo @(5/0); Check the following page for more information: http://www.php.net/manual/en/language.operators.precedence.php Hope this helps, Torben -- Torben Wilson <torben@php.net> http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506

« previous php.general (#83027) next »