In PHP, there's rarely a 'best' way to do anything - that's the beauty of PHP! Many ways to do things!
The example Nathan has given you is a indeed a correct way of dealing with the notice message you had. An alternative is: $value = (isset($_GET['foo'])) ? $_GET['foo'] : null; Same effect, just a different function used (and also works for checking normal variables such as $foo etc ) ~ C -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Michael Sent: Wednesday, 16 September 2009 1:30 p.m. To: [email protected] Subject: [phpug] Re: PHP 5.3.0 error On Wed, 16 Sep 2009 13:18:58 Cliff Black wrote: > It's standard practice to define/check variables or array keys for > existence before testing or calling them - in any language. The fact that > PHP has 'let you away with it' by removing the NOTICE or WARNING error > reports doesn't mean it's been acceptable, or recommended practice. > > PHP 5.3 implements a lot that will appear in the release of PHP6. > PHP6 is moving to standardize, and clean up the language - including > removing all the 'bad/lazy habits' that a lot of people have. > > $value = array_key_exists('retry',$_GET)?$_GET['retry']:null; So is this the 'best' way to handle it? --~--~---------~--~----~------------~-------~--~----~ NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [email protected] -~----------~----~----~----~------~----~------~--~---
