Re: $POST and $_SESSION

From: Date: Thu, 15 Mar 2012 18:41:41 +0000
Subject: Re: $POST and $_SESSION
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-317037@lists.php.net to get a copy of this message
On 15 Mar 2012, at 18:35, Daniel Brown wrote: > On Thu, Mar 15, 2012 at 14:31, Stuart Dallas <stuart@3ft9.com> wrote: >> >> The @ prefix is banned from all code I go anywhere near - it's evil! I've used >> the following 'V' function for a long time, primarily for accessing the superglobals but >> it works for any array. >> >> <?php >> session_start(); >> $_SESSION['first_name'] = $first_name = V($_SESSION, 'first_name'); >> >> function V($arr, $key, $def = null) { >> return isset($arr[$key]) ? $arr[$key] : $def; >> } >> ?> > > For the most part, I agree with you, but for this particular > example, it simply silences the notice for an undefined variable, > should it not be set, at the time of the function call. In nearly any > other case, though, I'm totally with you. I've seen too many cases where one "acceptable" use of the @ leads to bugs being hidden, regardless of the original motivation. I prefer to handle things like this explicitly, but each to his own. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/

« previous php.general (#317037) next »