Skip to content

Instantly share code, notes, and snippets.

@phoenixg
Created March 19, 2013 14:58
Show Gist options
  • Save phoenixg/5196820 to your computer and use it in GitHub Desktop.
Save phoenixg/5196820 to your computer and use it in GitHub Desktop.
<?php
// http://www.paulund.co.uk/encode-email-with-php
/**
* Encode an email address to display on your website
*/
function encode_email_address( $email ) {
$output = '';
for ($i = 0; $i < strlen($email); $i++)
{
$output .= '&#'.ord($email[$i]).';';
}
return $output;
}
$encodedEmail = encode_email_address( 'example@domain.com' );
printf('<a href="mailto:%s">%s</a>', $encodedEmail, $encodedEmail);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment