Re: Construct Request

From: Date: Thu, 15 Apr 2004 18:34:28 +0000
Subject: Re: Construct Request
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-9210@lists.php.net to get a copy of this message
On April 15, 2004 02:15 pm, Andi Gutmans wrote: > It could be implemented but I don't see the big advantage over $bar ? 0 : > $base It's one character... Well, currently to check the value and assign the default you need to do the following: $_GET['foo'] = isset($_GET['foo']) ? (int) $_GET['foo'] : 0; Which can get quite annoying if you need to repeat that many times and it's just easier to disable notices and do $_GET['foo'] = (int) $_GET['foo']; I think if anyone of the following would work it would be quite convenient isset_or_default($_GET['foo'], 0); /* if $_GET['foo'] is set leave as is, otherwise assign 0 to it */ $_GET['foo'] = isset_or_default($_GET['foo'], 0); /* same as above, but the variable is not passed by reference */ isset($_GET['foo']) ? : 0; /* Sascha's proposal */ Ilia

« previous php.internals (#9210) next »