Re: suppressing division by zero errors

From: Date: Thu, 31 Jan 2002 23:16:58 +0000
Subject: Re: suppressing division by zero errors
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83028@lists.php.net to get a copy of this message
You really need to do some error checking on the denominator. $num = 5; $den = 0; echo $den != 0 ? $num/$den : "0"; A number divided by zero isn't defined, so you have to circumvent the situation by making sure it never happens. ~Chris /"\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Fri, 1 Feb 2002, 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 >

« previous php.general (#83028) next »