note 29929 rejected from function.htmlentities by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 11:21:01 +0000 |
| Subject: | note 29929 rejected from function.htmlentities by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189580@lists.php.net to get a copy of this message | ||
Note Submitter: rob at neorosa dot com
----
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.