How to turn a URL into a hyperlink


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);
?>
Published by jak58 - Last update on August 2, 2009 12:50 PM by jak58
This document entitled « How to turn a URL into a hyperlink » from Kioskea.net (en.kioskea.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the licence, as this note appears clearly.
Suggestions
  •  How to turn a URL into a hyperlink
  •  Converting a URL to a clickable hyperlink » Tips : Converting a URL to a clickable hyperlink With regular expressions, it is possible to transform any hyperlink URL of the form http://URL (or ftp://URL) or beginning with www. : <? $message =...
  •  Laptop screen wont turn on (Solved) » Best answer: I had the same problem with my HP DV6599. On power on the screen would stay black, no POST, nothing at all on the display. The HDD would spin up but the HDD indicator would not come on and would not boot. The DVD drive would spin up and attem
  •  Laptop wont turn on (Solved) » Best answer: OK.....TRY TAKING OUT ANY CORDS AND TAKE OUT THE BATTERY AND HOLD THE LABTOP UPSIDE DOWN AND HOLD THE POWER BUTTEN FOR 30 SECONDS THEN TURN IT RIGHT SIDE UP AND PUT THE CORD BACK IN TRY TO TURN IT ON THEN PUT BATTERY BACK IN
  •  Acer laptop wont turn on (Solved) » Best answer: I've had this problem for a very long time. Two years or so. Finally I found a solution(s) based on trial and error on mine and others. The Aspire 5100 indeed has a major hardware flaw that engineers have overlooked and moved on. Rightfully s
  •  My laptop wont turn on (Solved) » Best answer: first of all as a static test i would remove the battery and power cable then hold the power button down for about 30 seconds. insert the battery and try turning it on now.
phpize: command not found
PhpMyAdmin - Access denied for user root@localhost