note 51184 deleted from function.ord by danbrown
| From: | danbrown@php.net | Date: | Tue, 11 Oct 2011 16:12:39 +0000 |
| Subject: | note 51184 deleted from function.ord by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183805@lists.php.net to get a copy of this message | ||
Note Submitter: Siegert Naber
----
The email-encoding function, a little extended:
# $strEmail. The E-mail address to encode.
# $strDisplay. What will be displayed in the browser. If omitted it takes the e-mail address as
it's value.
# $blnCreateLink. Set to true to creates a link. Set to false (and omit $strDisplay) just displays
the e-mail address.
function asciiEncodeEmail($strEmail,$strDisplay,$blnCreateLink) {
$strMailto = "mailto:";
for ($i=0; $i < strlen($strEmail); $i++) {
$strEncodedEmail .= "&#".ord(substr($strEmail,$i)).";";
}
if(strlen(trim($strDisplay))>0) {
$strDisplay = $strDisplay;
}
else {
$strDisplay = $strEncodedEmail;
}
if($blnCreateLink) {
return "<a
href=\"".$strMailto.$strEncodedEmail."\">".$strDisplay."</a>";
}
else {
return $strDisplay;
}
}
#examples:
echo asciiEncodeEmail("yourname@yourdomain.com","Your Name",true);
echo "<br />"
echo asciiEncodeEmail("yourname@yourdomain.com","",true);
echo "<br />"
echo asciiEncodeEmail("yourname@yourdomain.com","",false);