Re: proper method to do the following...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hugh Beaumont <hbeaumont@xxxxxxxxx> 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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux