Hi Derick,

I see. I was basing the spec on the functionality of isset() which does not (obviously) throw an E_NOTICE when you pass an undefined variable to it. However, do you see any reason that this would not reliably work?

function setor(&$param, $default)
{
    return (isset($param) ? $param : $default);
}

I tested it on 4.3.4 and 5.0 RC1, and it worked. Is passing an undefined variable as a reference parameter a legal thing to do in PHP?

~Jason



At 4/15/2004 09:54 PM +0200, Derick Rethans wrote:
On Thu, 15 Apr 2004, Jason Garber wrote:

> $_POST['CUST_ID'] = (int) isset_or_default($_POST['CUST_ID'], 0);
>
> I agree that it would be helpful not to evaluate the second parameter
> unless needed, which is why I originally proposed a language construct.

You'll need something more clever, because an undefined
key 'CUST_ID' in $_POST['CUST_ID'] will strill throw a warning, even if
you pass it to a language construct. Changing that behavior is not
trivial.

Derick

-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to