> function sureset($var) {
>
> if(!isset($var) || empty($var))
> return '';
> else
> return $var;
> }
>
> Of course, when you've got strict checking on, the above doesn't
> work, because if the variable is unset you get caught on the fact
> before the function call happens.

One change will make your code work: just pass the $var argument by
reference, ie. function sureset (&$var) { ...code... }

I wrote a similar function a while ago, with a little added functionality:

function get_if_set ( &$testVar, $falseValue = NULL)
{
    if ( isset( $testVar ) )
    {
        return $testVar;
    }
    else
    {
        return $falseValue;
    }
}



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

Reply via email to