1' , $text); $text = eregi_replace('([[:space:]()[{}"/> 1' , $text); $text = eregi_replace('([[:space:]()[{}">

Home  >  Article  >  Backend Development  >  exmail.qq.com Use PHP to convert URL string into hyperlink URL or email

exmail.qq.com Use PHP to convert URL string into hyperlink URL or email

WBOY
WBOYOriginal
2016-07-29 08:42:492010browse

Copy code The code is as follows:


function makeClickableLinks($text) {
$text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0- 9@:%_+.~#?&//=]+)', '1', $text);
$text = eregi_replace('([ [:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)','12', $text);
$text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a -z-]+.)+[a-z]{2,3})', '1', $text);
return $text;
}


Implementation principle:
Mainly using the regular principle to match URL characters or emails to replace them with hyperlinks.

The above has introduced the use of PHP to convert exmail.qq.com URL string into a hyperlink URL or email, including the content of exmail.qq.com. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn