0

I want to encode an email id in a text box. An email id is saved in database. When page loads i retrieve email id from database using php and display in text input and when i see the email id in page source then the email id should be encoded. How to do this using php and html?

1 Answers1

0

Try this:

function encode_email($e) {
  $output = '';
  for ($i = 0; $i < strlen($e); $i++) { $output .= '&#'.ord($e[$i]).';'; }
  return $output;
}

 echo(encode_email('[email protected]'));
Engineer
  • 5,911
  • 4
  • 31
  • 58