'filter' extension: Initial thoughts
Posted: Sat Nov 04, 2006 7:51 pm
First of all, filter is beta software and as such should not be relied on. Second of all, it's only of PHP 5.2.0, so if you want your application to be portable, avoid filter. Finally, the documentation is woefully inadequate, so I'm going off what the tutorial here says.
First of all: filter_has_var() has to be one of the most useless functions ever created. isset($_POST['key']) clocks at 20 characters while filter_has_var(INPUT_POST,'key') has 32 characters, but they do exactly the same thing. I'll reconsider when you allow this syntax: filter_has_var_all(INPUT_POST, 'key1', 'key2', 'key3', 'key4'); I can perhaps see why you'd want to use this for uniformity, but... once again, not convinced of utility.
Second of all: the lack of documentation is a real killer, because how am I supposed to know exactly how the "email" filter works? What kind of emails does it allow? Is it well tested or a haphazard implementation? Does it go RFC or practical?
Third of all: it does have potential. The tutorial doesn't precisely do a very good job of showing us why you'd want to use filter, just how. I expect that a comparison between pre-filter and post-filter code would enlighten us more. __pierre alludes to getting rid of "the isset or is_numeric mess," but the filter syntax seems very verbose as well.
First of all: filter_has_var() has to be one of the most useless functions ever created. isset($_POST['key']) clocks at 20 characters while filter_has_var(INPUT_POST,'key') has 32 characters, but they do exactly the same thing. I'll reconsider when you allow this syntax: filter_has_var_all(INPUT_POST, 'key1', 'key2', 'key3', 'key4'); I can perhaps see why you'd want to use this for uniformity, but... once again, not convinced of utility.
Second of all: the lack of documentation is a real killer, because how am I supposed to know exactly how the "email" filter works? What kind of emails does it allow? Is it well tested or a haphazard implementation? Does it go RFC or practical?
Third of all: it does have potential. The tutorial doesn't precisely do a very good job of showing us why you'd want to use filter, just how. I expect that a comparison between pre-filter and post-filter code would enlighten us more. __pierre alludes to getting rid of "the isset or is_numeric mess," but the filter syntax seems very verbose as well.