phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Web Content: Protecting E-mail Address

Tag: web content, email   Category: PHP Basic
post: 27 Apr 2008 read: 274


Web Content Tips - Part 3: Because any spam out of there, we need protect our public email address from being captured by and e-mail address harvester. We ever talk about protecting email at here. At that post, we use JavaScript. In this post, we use different approach.

In this post, we try to modify text. Example, we want to display "me_you@sub.mysite.com". We will display become "me underscore you at sub dot mysite dot com". Look the code:


<?php
function protectEmail($email){
  $search = array(".", "@", "_", "-");
  $replace = array(" dot ", " at ", " underscore ", " dash ");
  
  return str_replace($search, $replace, $email);
}

$email = "me_you@sub.mysite.php";

echo protectEmail($email);
// result: me underscore you at sub dot mysite dot php
?>



| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
PHP WDDX: Recordset Element
Joomla: Fast Road to Understand Component Programming
Web Services: How PHP Kiss VB.NET? (Part 1)
mod_rewrite - Part 1: create your "fantasy" URL
PHP Supported Metacharacters (You Must Know Them)

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


624
posting