email protector:这个代码今天仍然安全吗?

I found this nice email protector script from css-tricks.com (link)

Here is the code:

<?php
    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>";
                document.write(a+b+"@"+c+d+b+"@"+c+e);
            </script>
            <noscript>Please enable JavaScript to view emails</noscript>
        ';
    }
?>

Usage

<?php php_split_js_make_email("youremail@here.com"); ?>

Now I would like to know how secure this code is today, since this post is more than a year old now...

Thank you

The script is only secure if the robot sniffing your page for email addresses doesn't execute the JavaScript.

On my personal site, I embed my email address as an image and use an online form to send mail instead of a mailto link.

I guess you want to protect against bots harvesting email adresses? Then probably not. More and more scrapers are able to execute javascript code, tools like phantomjs make it easy to scrape contents of javascript sites.

In general you should try not to expose such data publicly. How many of the people visiting your page are interested in the address?

Consider to add some kind of authentication check like a captcha or login process for those people. Or to put it the other way round: Dont show everyone sensitive data you don't want to have scraped. And keep in mind that there is no 100% protection against scrapers. Oh, and when using captchas please use something sensible! I would bet most bots can solve that re-captcha service better then me ... In many cases you are fine with a very basic set of "common sense" questions.