Email Protector

	function php_split_js_make_email($phpemail)
		$pieces = explode("@", $phpemail);
		echo '
			<script type="text/javascript">
				var a = "<a href=\'mailto:";
				var b = "' . $pieces[0] . '";
				var c = "' . $pieces[1] .'";
				var d = "\' class=\'email\'>";
				var e = "</a>";
			<noscript>Please enable JavaScript to view emails</noscript>


<?php php_split_js_make_email(""); ?>

Reference URL


  1. The Frosty
    Permalink to comment#

    That’s a nice way to obscure an email. I’ve always used WordPress’ antispambot&sup1;. But for a project outside of WP…


  2. Chester
    Permalink to comment#

    Where would I put the PHP function? Inline with the html?
    Will a PHP function run in my index.html?


  3. Andrew
    Permalink to comment#

    @chester – you can run php in .html files, but you might also need to enable apache via .htaccess to run php in a .html with a line like this in your .htaccess file:

    AddType application/x-httpd-php .html .htm

  4. sandy
    Permalink to comment#

    i want to a php code to detach the mail from body .. please give reply..

  5. djave

    I actually updated this email protector and it
    can be found here with a couple of new arguments (Same link as above)

Leave a Comment

Posting Code

We highly encourage you to post problematic HTML/CSS/JavaScript over on CodePen and include the link in your post. It's much easier to see, understand, and help with when you do that.

Markdown is supported, so you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences like this:

  function example() {
    element.innerHTML = "<div>code</div>";

We have a pretty good* newsletter.