Re: Construct Request

From: Date: Thu, 15 Apr 2004 20:00:31 +0000
Subject: Re: Construct Request
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-9220@lists.php.net to get a copy of this message
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


« previous php.internals (#9220) next »