Re: proper method to do the following...

From: Date: Wed, 06 Oct 2004 15:31:58 +0000
Subject: Re: proper method to do the following...
Groups: php.general 
Request: Send a blank email to php-general+get-198760@lists.php.net to get a copy of this message
Hugh Beaumont <hbeaumont@yahoo.com> wrote: <quote -------------------------------------------------------------------->
I've been working with error_reporting(E_ALL) set lately trying to write code that does not give notices or errors.
What is the proper way to set a variable so that it's non-existance
will not generate
a notice?
Thanks all for the replies. I also noticed a small typo in the code I posted which made it even worse (used == instead of = when doing the assignment). <quote --------------------------------------------------------------------> There's a book called XX number of ways to improve your C++ code. Well, it works on lots of languages. About equality statements? Put the constant on the left, then it's not accidentally an assignement. if( 15==$dudes_age ){ $action="Slap him if he looks at your daughter"; } vs if( $daughters_age==(18*365 + 4 + 1) ){ $action="Give her a box of con***s and kick her out"; } //18 years, plus 4 leap days plus one day. If you accidentally mamke the '==' a '=' in the second statement, it will always be true, and you will get arrested for kicking your 8 year old out into the street.

« previous php.general (#198760) next »