Re: ifsetor like expression in php6

From: Date: Sat, 26 Jan 2008 18:17:52 +0000
Subject: Re: ifsetor like expression in php6
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-34942@lists.php.net to get a copy of this message
On Saturday 26 January 2008 18:22:09 Sam Barrow wrote: > I'm sorry I misunderstood. If specifying like "$var ?: 5" then it should > throw an E_NOTICE, as this is a conditional that checks the value of a > variable ($var). > > Sebastian, for assigning of a default value is a variable is not set, I > would recommend using something like this (this is what I use): > > function ifsetor(&$var, $or) { > return isset($var) ? $var : $or ; > } That magically brings $foo into life if you do ifsetor($foo, 2).

« previous php.internals (#34942) next »