Re: Implicit isset/isempty check on short-ternary operator

From: Date: Thu, 14 Apr 2011 16:20:55 +0000
Subject: Re: Implicit isset/isempty check on short-ternary operator
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  Groups: php.internals 
Request: Send a blank email to internals+get-51907@lists.php.net to get a copy of this message
Nope. I prefer to treat "invalid" or "non existing" basic types as them being set to a default value. This makes the input handler very robust and I don't have to waste time by writing code that handles failed validation. For example if I read an integer from $_POST I'd simply write: $value = \intval(@$_POST["field"]); (or a boolean:) $value = (@$_POST["field"] == "set"); I'd prefer this syntax though: $value = \intval($_POST["field"]??); ..simply because it's a more precise expression and no notice is generated and have to be ignored when running the custom error handler - so it should be faster too. ~Hannes On 14 April 2011 18:08, Ole Markus With <olemarkus@olemarkus.org> wrote: > On Thu, 14 Apr 2011 16:05:45 +0200, Hannes Landeholm <landeholm@gmail.com> > wrote: > > So basically the discussion now is what exact characters that should be >> used >> to represent this operator? I really hope we can get this implemented >> quickly... I worked with $_POST yesterday and I could really use that ?? >> operator. >> >> > When it comes to $_POST you probably want to use filter_input instead. > > Cheers, > Ole Markus With >

« previous php.internals (#51907) next »