Feature Request
| From: | Scott Stevenson | Date: | Mon, 23 Aug 1999 22:29:21 +0000 |
| Subject: | Feature Request | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-3667@lists.php.net to get a copy of this message | ||
PHP3 has some really handy functions for dealing with strings, such as
nl2br, htmlspecialchars, addslashes, chop, etc. Basically, things that can
be accomplished with regular expressions, but are far more convenient and
easy to use.
In a slightly different vein, it would be nice if there were some functions
for dealing with form validation. First and foremost, this is important for
security reasons. As far as I can tell, PHP doesn't have anything like
Perl's -T option, and I'm a little concerned about what's coming down the
pipe. Secondly, it would be nice to know if you're getting what you asked
for.
The functions would do things like search a string for a valid email
address, valid phone number, or a zip/country code -- stripping out any
potentially dangerous (or incorrect) characters. Ideally, this would work
like:
<form action="mail.phtml" method="post">
<input type="text" name="email_addr">
<input type="text" name="phone_num">
<input type="zip" name="zip_code">
</form>
------
$cleanEmail = get_email($email_addr);
$cleanPhone = get_phone($phone_num);
$cleanZip = get_uszip($zip_code);
A regex would be applied to find what you're looking for, and failing that,
the function would return a false. Making this type of stuff into neat
little functions makes it more accessible to newbies, and more elegant for
normal users. It's sort of the "PHP way". :)
I'd do this myself, but I'm not fluent in C.
- Scott