源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Email+URL的判断和自动转换函数

  • 时间:2021-05-28 01:55 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Email+URL的判断和自动转换函数
<?php function validateEmail($email)   {     return eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $email);   }   function validateURL($url)   {     return eregi("^((ht|f)tp://)((([a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3}))|(([0-9]{1,3}.){3}([0-9]{1,3})))((/|?)[a-z0-9~#%&'_+=:?.-]*)*)$", $url);   }   function convertURLS($text)   {     $text = eregi_replace("((ht|f)tp://www.|www.)([a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})((/|?)[a-z0-9~#%&\/'_+=:?.-]*)*)", "http://www.\3", $text);       $text = eregi_replace("((ht|f)tp://)((([a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3}))|(([0-9]{1,3}.){3}([0-9]{1,3})))((/|?)[a-z0-9~#%&'_+=:?.-]*)*)", "<a href="\0">\0</a>", $text);       return $text;   }   function convertMail($text)   {     $text = eregi_replace("([_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3}))", "<a href='mailto:\0'>\0</a>", $text);       return $text;   }   function convertAllLinks($text)   {     $text = convertURLS($text);       $text = convertMail($text);       return $text;   } ?>  
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部