Re: [PHP-DEV] suggestion about ternary operator

2009-11-22 Thread Lukas Kahwe Smith
On 22.11.2009, at 03:13, D. Dante Lorenso wrote: > Lukas Kahwe Smith wrote: >> On 21.11.2009, at 22:29, Dante Lorenso wrote: >>> I would love to restate my recommendation for the function "filled". >>> Which is the opposite of "empty". Filled would accept a variable >>> number of arguments and r

Re: [PHP-DEV] suggestion about ternary operator

2009-11-21 Thread Alban
Le Sat, 21 Nov 2009 19:52:30 -0800, Rasmus Lerdorf a écrit : > > Or better yet, have your filter function return false if the variable > doesn't exist and use the ternary to set the default. You can do it all > in a single step then. > > $var = filter_func($_GET,'foo')?:42; > > Simple and clea

Re: [PHP-DEV] suggestion about ternary operator

2009-11-21 Thread Rasmus Lerdorf
Alban wrote: > Le Sat, 21 Nov 2009 10:21:18 -0800, Rasmus Lerdorf a écrit : >> The ternary isn't meant to solve the isset thing you are talking about. >> It is simply a shortcut to normal ternary operations. The most common >> case where you don't know if a variable is set is on the initial input

Re: [PHP-DEV] suggestion about ternary operator

2009-11-21 Thread Alban
Le Sat, 21 Nov 2009 10:21:18 -0800, Rasmus Lerdorf a écrit : > > The ternary isn't meant to solve the isset thing you are talking about. > It is simply a shortcut to normal ternary operations. The most common > case where you don't know if a variable is set is on the initial input > via $_GET or

Re: [PHP-DEV] suggestion about ternary operator

2009-11-21 Thread D. Dante Lorenso
Lukas Kahwe Smith wrote: On 21.11.2009, at 22:29, Dante Lorenso wrote: I would love to restate my recommendation for the function "filled". Which is the opposite of "empty". Filled would accept a variable number of arguments and return the first where empty evaluates as false. Like empty, fil

Re: [PHP-DEV] suggestion about ternary operator

2009-11-21 Thread Lukas Kahwe Smith
On 21.11.2009, at 22:29, Dante Lorenso wrote: > I would love to restate my recommendation for the function "filled". > Which is the opposite of "empty". Filled would accept a variable > number of arguments and return the first where empty evaluates as > false. > > Like empty, filled would not t

Re: [PHP-DEV] suggestion about ternary operator

2009-11-21 Thread Dante Lorenso
I would love to restate my recommendation for the function "filled". Which is the opposite of "empty". Filled would accept a variable number of arguments and return the first where empty evaluates as false. Like empty, filled would not throw notices for undefined variables. This is not the same a

Re: [PHP-DEV] suggestion about ternary operator

2009-11-21 Thread mm w
More interesting behaviors to dig are there: variable = ?? ; variable = ? : ?? ; or a la javascript variable = || ; Best, On Sat, Nov 21, 2009 at 10:21 AM, Rasmus Lerdorf wrote: > Alban wrote: >> Le Sat, 21 Nov 2009 09:48:10 +0100, Lukas Kahwe Smith a écrit : >> >>> On 21.11.2009, at 0

Re: [PHP-DEV] suggestion about ternary operator

2009-11-21 Thread Rasmus Lerdorf
Alban wrote: > Le Sat, 21 Nov 2009 09:48:10 +0100, Lukas Kahwe Smith a écrit : > >> On 21.11.2009, at 06:12, Alban wrote: >> >>> This is not a big problem but if a solution exists, this would be so >>> cool ! Especialy when we have to check existance of twenty or more key >>> in array. Code would

Re: [PHP-DEV] suggestion about ternary operator

2009-11-21 Thread Alban
Le Sat, 21 Nov 2009 09:48:10 +0100, Lukas Kahwe Smith a écrit : > On 21.11.2009, at 06:12, Alban wrote: > >> This is not a big problem but if a solution exists, this would be so >> cool ! Especialy when we have to check existance of twenty or more key >> in array. Code would be be lighter and cle

Re: [PHP-DEV] suggestion about ternary operator

2009-11-21 Thread Lukas Kahwe Smith
On 21.11.2009, at 06:12, Alban wrote: > This is not a big problem but if a solution exists, this would be so > cool ! Especialy when we have to check existance of twenty or more key in > array. Code would be be lighter and clear. > Since i use PHP, I always have in my 'common function file' a f

Re: [PHP-DEV] suggestion about ternary operator

2009-11-20 Thread Alban
Le Fri, 20 Nov 2009 23:28:39 -0600, Larry Garfield a écrit : > On Friday 20 November 2009 11:12:29 pm Alban wrote: > >> This is not a big problem but if a solution exists, this would be so >> cool ! Especialy when we have to check existance of twenty or more key >> in array. Code would be be ligh

Re: [PHP-DEV] suggestion about ternary operator

2009-11-20 Thread Larry Garfield
On Friday 20 November 2009 11:12:29 pm Alban wrote: > This is not a big problem but if a solution exists, this would be so > cool ! Especialy when we have to check existance of twenty or more key in > array. Code would be be lighter and clear. I cannot comment on the rest of your post right now,

[PHP-DEV] suggestion about ternary operator

2009-11-20 Thread Alban
hi all, Since the new conditionnal operator ternary was introduced in php 5.3, I'm little confuse about it. The documentations says : Since PHP 5.3, it is possible to leave out the middle part of the ternary operator. Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and ex