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, filled would not throw notices for undefined variables.
This is not the same as the ifsetor debate because filled is opposite
empty and cares not about isset.
did you even read the RFC?
Yes I did, and all I see is this in the References section:
"Suggestion to leave an empty() variant out of the picture since
this feature can be implemented in userland, though this of
course not provide the full functionality of empty() which
does not trigger notices for missing variables"
I didn't see my proposal listed in it anywhere. See this recommendation
from 3 1/2 years ago:
- May 03, 2006
http://www.mail-archive.com/internals@lists.php.net/msg21617.html
Can someone please add the 'filled' proposal to the RFC? I find
'filled' way more useful than 'ifsetor' because in everyday code, I am
constantly wanting to assign default values to variables that don't have
values for a variety of reasons. The assignment of a default value
happens before input filtering.
$email = filled(
$_REQUEST['email'],
$CONFIG->email_default,
$class_email,
'defa...@domain'
);
Give me the first non-empty value and don't throw NOTICE warnings about
it. Otherwise, I need all this:
$email = !empty($_REQUEST['email']) ? $_REQUEST['email'] : (
!empty($CONFIG->email_default) ? $CONFIG->email_default : (
!empty($class_email) ? $class_email : 'defa...@domain'
));
Yuck.
-- Dante
----------
D. Dante Lorenso
da...@lorenso.com
972-333-4139
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php