Location: PHPKode > scripts > Force HTML Entities > forceHTMLentities/forceHTMLentities.php
<?php
/*
** Please do not remove this comment!
** Use of this Software implies explicit agreement to the Terms of
** Use (http://artbyjb.com/terms/) and the End-User Software License
** Agreement (http://artbyjb.com/terms/eula). This Software is
** provided on an "as-is" basis and cannot be guaranteed to be free
** of defects or that the Software will meet your requirements.

** Title: Force HTML Entities
** Description: This PHP script returns all of the characters in a string as HTML entities. Using this function when publishing e-mail addresses can help prevent web spiders from harvesting the data to send you spam.

** Author: Jeffrey Bennett
** URL: http://artbyjb.com/code/?p=10
** Date: January 23, 2011

** @access	public
** @param	string	$str	(required)
** @return	string
*/

function forceHTMLentities($str) {
 $str = str_split($str);
 $content = "";

 foreach ($str as $value) {
  $content .= preg_replace('/\\\\U0*([0-9a-fA-F]{1,5})/', '&#x\1;', "\U00" . bin2hex($value));
 }

 return $content;
}
?>
Return current item: Force HTML Entities