> Of course it is possible to create a class with this behavior using
> SPL, but that doesn't take care of the superglobals and there might be
> performance problems.
>
> -John Campbell

Well,  I've got a 'framework' that I use for my own projects that I call "PHP 
on Nails".  It has several levels,  and "level 0" is the most mature.  It's 
mostly about configuration management,  tightening error handling and reducing 
with variations between environments.

It introduces a few single-letter functions,  such as

Q($string):  almost the same as echo(htmlspecialchars($string)) except it maps 
the empty string to     Your designer and junior programmers ~might~ 
actually use it in a template.  I'm thinking about expanding UTF-8 unicode 
characters to numeric form here too.

G($key) and P($key):  which replace $_GET and  $_POST while doing a few kinds 
of filtering.  If the key is undefined,  it returns the empty string.  
Whitespace gets trimmed from the beginning and end of the strings.  
magic_quotes_gpc is undone if set.

Perhaps it's a bit crazy to use single character function names,  but my take 
is that these function greatly improve the security and reliability of PHP 
applications IF people actually use them.  If the names were like

get_and_filter_post_variable

they wouldn't get used.  Someday I'll release the level 0 library and blog 
about it.
 
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to