How to Encode PHP in an Email Address

104 10
    • 1). Open the PHP file that handles sending out emails to users using a text editor or web-authoring tool.

    • 2). Type in a new function that will encode the email.

      "<?php

      Function emailEncode($email_address) {

      if(filter_var($email_address, FILTER_VALIDATE_EMAIL) !== FALSE)

      {

      $char_Array = str_split($email_address);

      $encoded_Array = filter_var($char_Array, FILTER_CALLBACK, array('options'=>""));

      $encoded_String = implode('',$encoded_Array);

      return '<a href="/links/?u=mailto:'.$encoded_String.'">'.$encoded_String.'</a>';

      }

      else

      {

      return false;

      }

      }"

    • 3). Type in the PHP code that calls on the "emailEncode" function you created. Place this anywhere in the code after the code that gathers the email address from the user.

      "echo emailEncode($email_address);"

      Close up the PHP coding by placing "?>" at the end of the document. Closing the PHP code lets the server know that its job is done and there is no more PHP code to run.

    • 4). Save the PHP file and upload it to your web server.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.