You are here: Re: [PHP] Re: XML Filters for illegal characters « PHP « IT news, forums, messages
Re: [PHP] Re: XML Filters for illegal characters

Posted by John Holmes on 01/05/05 23:54

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация