Re: $POST and $_SESSION

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

 



How about this?

$first_name = @$_POST['first_name'] or $first_name =
$_SESSION['first_name'] ? $_SESSION['first_name'] : null;

Thanks,
Michael

On Fri, Mar 16, 2012 at 2:13 AM, Daniel Brown <danbrown@xxxxxxx> wrote:
> On Thu, Mar 15, 2012 at 11:04, Tedd Sperling <tedd.sperling@xxxxxxxxx> wrote:
>> Hi gang:
>>
>> What's a better/shorter way to write this?
>>
>> $first_name = $_SESSION['first_name'] ? $_SESSION['first_name'] : null;
>> $first_name = isset($_POST['first_name']) ? $_POST['first_name'] : $first_name;
>> $_SESSION['first_name'] = $first_name;
>
>    A simple reusable function and pass-through variable is one method:
>
> <?php
>
>    session_start();
>    $_SESSION['first_name'] = $first_name =
> thisorthat(@$_POST['first_name'],null);
>
>    function thisorthat($a,$b) {
>        return isset($a) ? $a : $b;
>    }
>
> ?>
> --
> </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
>

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