Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Marco Tabini's Blog:
Input filtering
Aug 29, 2005 @ 10:41:16

In a new post over on Marco Tabini's weblog today, he talks about everyone's favorite topic these days when it comes to PHP - input filtering - from a more PHP5 perspective.

One of the aspects of PHP 5 that I like the most is the fact that new features like the SPL allow the developer to really plug himself into the language directly from userland.

Now that I have built BeebleX, and now that we’re starting to redesign the frontend of php|architect, I have a much better idea of what can be done and, frankly, I would dread having to go back to PHP 4.

Take, for example, input filtering. As you may know, Derick has been working on a proposal for a filtering extension to be written into PHP 6 (and, I hope, as a PECL extension that can be backported to PHP 5.x as well). However, you don’t have to wait until this is released to introduce a painless (but very effective) way to provide input filtering in your PHP 5 applications.

He includes an example of what he means in the form of a filtering class written for the PHP5 users out there. It takes in the data and, depending on what function you call on the data (like html(), url(), or email()), it will spit back that data all filtered to match that data type. Prepend the class to your scripts and redeclare your superglobabls with it and you have "filtering-enabled versions of themselves"...

tagged:

Link:


Trending Topics: