PHP | How to effectively block email against bots in PHP

How to effectively protect your e-mail address on the website? Sometimes there is a problem with spam that comes to us by e-mail.

Solving the problem, however, is extremely simple. For your website add the following PHP script that converts the e-mail address to a string, which is, however, properly displayed on the website.

function convert_email($email) {     $p = str_split(trim($email));     $new_mail = '';     foreach ($p as $val) {          $new_mail .= '&#'.ord($val).';';     }     return $new_mail;}

Parameter that we pass to the function is the e-mail address that you want to hide against bots. First, we remove empty, white characters from the address, and then divide it into single characters. Then we create a new string, which is formed by converting to the ASCII character code. That would be enough. Result we display on the site. Seemingly not see any difference. However, as we check the page source, we will see a string like below.

 

Contact