Re: ifsetor like expression in php6

From: Date: Sat, 26 Jan 2008 17:17:24 +0000
Subject: Re: ifsetor like expression in php6
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-34940@lists.php.net to get a copy of this message
I don't think throwing a E_NOTICE is appropriate. The isset() construct doesn't throw an E_NOTICE, this shouldn't either. On Sat, 2008-01-26 at 17:30 +0100, Sebastian wrote: > hi, > > i just found the new ifsetor like construction in php6. It left me the > question why php has to throw an E_NOTICE when the variable is not set. This > is basicly because that actually is the meaning of this construction, > checking if the variable is set and if it isnt give back a standard value. > Of course i know this construction can be (mis)used with an Boolean check > ($var===$var2), but this does not make much sence either because TRUE will > then be assigned to the new variable if the expression evaluates to TRUE > (but please correct me if theres a real use for this). > > So in any case it would be better to remove the Boolean check feature and > make it a simple ifsetor() without the E_NOTICE again. > > For those of you who have not heard of it heres an example: > > <?php > > // If $_GET['foo'] is set, then its value will be assigned to $foo, > // otherwise 42 will be assigned to $foo. > > $foo = $_GET['foo'] ?: 42; > > ?> > > Greetings > > Sebastian >

« previous php.internals (#34940) next »