note 29929 modified in function.htmlentities by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 17:11:51 +0000 |
| Subject: | note 29929 modified in function.htmlentities by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154955@lists.php.net to get a copy of this message | ||
This function will encode everything, either using ascii values or special entities:
<?php
function encode_everything($string){
$encoded = "";
for ($n=0;$n<strlen($string);$n++){
$check = htmlentities($string[$n],ENT_QUOTES);
$string[$n] == $check ? $encoded .= "&#".ord($string[$n]).";" :
$encoded .= $check;
}
return $encoded;
}
?>
so you can use:
<?php $emailAddress = encode_everything($emailAddress); ?>
to protect an email address - although I imagine it's not a great deal of protection.
--was--
This function will encode everything, either using ascii values or special entities:
function encode_everything($string){
$encoded = "";
for ($n=0;$n<strlen($string);$n++){
$check = htmlentities($string[$n],ENT_QUOTES);
$string[$n] == $check ? $encoded .= "&#".ord($string[$n]).";" :
$encoded .= $check;
}
return $encoded;
}
so you can use:
$emailAddress = encode_everything($emailAddress);
to protect an email address - although I imagine it's not a great deal of protection.
http://php.net/manual/en/function.htmlentities.php