Re: htmlspecialchars() alias
| From: | Daniel Lorch | Date: | Thu, 17 Jan 2002 19:52:35 +0000 |
| Subject: | Re: htmlspecialchars() alias | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-77365@lists.php.net to get a copy of this message | ||
Hi,
> After typing the 16 characters in the htmlspecialchars() function thousands
> of times...
When you have to type it 16 times, then you did something wrong.
Consider this:
foreach($_GLOBAL as $key => $val)
$$key = htmlspecialchars($val);
Replace $_GLOBAL by $_COOKIES, $_GET, .. OR you could just group
together variables:
<input type="text" name="form[name]" ..>
and go through $form in your script.
> I was wondering if it would be feasible to create an alias for this
> function, say hsc() or something short.
> [..]
> It is no big deal, but for a function that is used ALL THE TIME, it would
> be nice.
why do something in C, when it can be done in PHP so nicely:
function hsc(&$var) {
$var = htmlspecialchars($var);
}
Alias are terrible. The decrease readability of your code. Actually
doing hsc() in PHP is compareable silly.
Kind Regards,
Daniel Lorch
--
@echo "Hello, World";