D. Dante Lorenso wrote:
In my PHP zen world, empty() and filled() are friends. Ok, I've been
selling 'filled()' for a while now. Can we reverse the sell and try
this .. why SHOULDN'T filled() be added to the language?
Because it doesn't do enough. Unlike empty(), when there actually is
something there, you have to check the type before using it anyway.
eg.
$a = filled($_GET['a'],$_GET['b']);
You still have to do:
if(!is_array($a)) echo $a;
Because people could put ?a[]=1 in the GET args there and you have to
check for that before using it. That second type check defeats the
purpose of filled() as far as I am concerned. We need a quick way to do
a check and default assignment without throwing a notice which is what
?: provides, then we need a decent way to check input arguments which is
what pecl/filter is being brought into the core for (among other things).
See:
http://www.php.net/~derick/meeting-notes.html#ifsetor-as-replacement-for-foo-isset-foo-foo-something-else
By the way, the lack of array checks is rampant out there. Pick just
about any PHP site and find a page where it has arguments and add [] to
one of them and watch it blow up. In some cases where the developers
were smart enough to send errors to their error log, you can't see that
you made it blow up, but in surprisingly many you can:
http://en.wikipedia.org/w/index.php?title[]=Special:Userlogin&returnto[]=Main_Page
-Rasmus
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php