Re: what happened to that new isset() like language

From: Date: Sun, 30 Oct 2005 20:57:07 +0000
Subject: Re: what happened to that new isset() like language
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-19852@lists.php.net to get a copy of this message
The function I used in my post does not generate an E_NOTICE, because a call-by-reference can be done with an unset variable (that can be set from the function). <?php error_reporting(E_ALL); function ifsetor(&$var, $value) { return (isset($var)) ? $var : $value; } echo ifsetor($bla, 'test'); ?> This simply prints 'test' and shows no errors. In fact, a var_dump() on $bla will show that it's become NULL. Never mind this whole ifsetor() in userspace issue, because it's not applicable anyway, but just for the record, this function does not generate an E_NOTICE. Ron "Jasper Bryant-Greene" <jasper@album.co.nz> wrote in message news:1130700022.3009.1.camel@jasper.local... > On Sun, 2005-10-30 at 09:52 +0100, Ron Korving wrote: > > I'm a big fan of coalesce($param1, $param2, ..., $paramN) (or firstset()). > > The syntax allows for more than what ifsetor($var, $value) would do. > > Ifsetor() could be done in userspace, but I don't see how coalesce() could, > > because of the variable number of parameters. > > It's not so much the variable number of parameters as the fact that it > has to receive a variable that may not be set. Using a user-space > function will cause an E_NOTICE to be thrown every time the function is > used, because it's receiving an unset variable. It needs to be a > language construct. > > FWIW, I like the $a ?? $b and $a ??= $b idea. > > -- > Jasper Bryant-Greene > General Manager > Album Limited > > e: jasper@album.co.nz > w: http://www.album.co.nz/ > b: http://jbg.name/ > p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303 > a: PO Box 579, Christchurch 8015, New Zealand

« previous php.internals (#19852) next »