0
Thanks

A few words of thanks would be greatly appreciated.

How to turn a URL into a hyperlink






If you are using PHP, there is a simple way to turn a URL into a hyperlink when inserting the address into your PHP document. This process is mostly used to ease the users' search of external websites or pages; there are no copy and paste issues that he will have to face to be able to visit the desired page. It also saves much time and will make your webpage more user friendly.

You can copy and paste the link below in your PHP document:

<?
$message = eregi_replace("((([ftp://])|(http(s?)://))((:alnum:|[-\%\.\?\=\#\_\:\&\/\~\+\@\,\;])*))","<a href = '\\0' target='_blank'>\\0</a>",$message);

$message = eregi_replace("(([^/])www\.|(^www\.))((:alnum:|[-\%\.\?\=\#\_\:\&\/\~\+\@\,\;])*)","\\2<a href = 'http://www.\\4' target='_blank'>www.\\4</a>",$message);
?>
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Published by . Latest update on by jak58.

This document, titled "How to turn a URL into a hyperlink," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

1 Comment