Re: Re: XML Filters for illegal characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jones, Douglas 1 wrote:
I think that a function just like htmlentities but one
> that just removes characters that are illegal but can not
> be fixed would be the ideal solution.

How do you define what can and cannot be fixed, though? You'd have to know the "bad" characters and in that case, a simple str_replace() is all you need.

$bad_characters = array('^','*','#');
$text = str_replace($bad_characters,'',$text);
$text = htmlentities($text);

Or, since you don't really know what's "bad" then you'd want to define what's good. You could use get_html_translation_table() to find everything that htmlentities() will convert and then combine those characters, alphanumeric characters and whitespace into a preg_replace to match anything that's *not* one of those characters and erase it.

--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux