How to turn a URL into a hyperlink

April 2018

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);
Published by jak58. Latest update on August 2, 2009 at 08:50 AM 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 (
phpize: command not found
PhpMyAdmin - Access denied for user root@localhost