Re: $POST and $_SESSION

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

 



On Thu, Mar 15, 2012 at 14:31, Stuart Dallas <stuart@xxxxxxxx> 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.

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

-- 
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