How Do I Make My Text Clickable
RegisterLogin
How Do I Make My Text Clickable
Post Description: How Do I Make My Text Clickable
Tags: How, Do, I, Make, My, Text, Clickable
This Post Was Posted On Apr 24, 2008 By petruslima #1373
Post Description: How Do I Make My Text Clickable
Tags: How, Do, I, Make, My, Text, Clickable
This Post Was Posted On Apr 24, 2008 By petruslima #1373
How Do I Make My Text Clickable by petruslima
is that hard to do with php?
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
alexadira
#2422 1
please show me Making Text URLs Into Clickable Links Tutorial.
thanks
thanks
Sep 26, 2009 Reply Report abuse
Web Hosting Support
#1792 2
no its not let me show you
here is a php code. just copy and past to notepad and save it as webune.php and upload to your php website and open it with your browser and see it in action
hope this helps
here is a php code. just copy and past to notepad and save it as webune.php and upload to your php website and open it with your browser and see it in action
<?
function clickable_link($text)
{
# this functions deserves credit to the fine folks at phpbb.com
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "1:", $text);
// pad it with a space so we can match things at the start of the 1st line.
$ret = ' ' . $text;
// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, comma, double quote or <
$ret = preg_replace("#(^|[n ])([w]+?://[w#$%&~/.-;:=,?@[]+]*)#is", "1<a href="2" target="_blank">2</a>", $ret);
// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// zzzz is optional.. will contain everything up to the first space, newline,
// comma, double quote or <.
$ret = preg_replace("#(^|[n ])((www|ftp).[w#$%&~/.-;:=,?@[]+]*)#is", "1<a href="http://2" target="_blank">2</a>", $ret);
// matches an email@domain type address at the start of a line, or after a space.
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
$ret = preg_replace("#(^|[n ])([a-z0-9&-_.]+?)@([w-]+.([w-.]+.)*[w]+)#i", "1<a href="mailto:2@3">2@3</a>", $ret);
// Remove our padding..
$ret = substr($ret, 1);
return $ret;
}
$text="www.webune.com";
?>
<HTML>
<TITLE>Making Text URLs Into Clicable Links Tutorial</TITLE>
<HEAD>
<style type="text/css">
<!--
.style2 {color: #0066FF}
-->
</style>
</HEAD>
<BODY>
<h1 align="center" class="style2">Making Text URLs Into Clicable Links Tutorial</h1>
<p>the clickable link is before function is: <strong><?php echo $text; ?></strong></p>
<p>this is the text after the <span class="style2">clickable_link_function</span>: <?php echo clickable_link($text); ?> </p>
<hr size="2" noshade>
<p> If you have benefited or learned from this short "Howto" tutorial, we would appreciate if you can provide a link to our http://www.webune.com. By linking to webune, you will make these tutorials more available to others who are looking for information like this.</p>
<p>Thank You</p>
<p>webune Team</p>
<p><a href="http://www.webune.com/forums"><< Go Back</a> </p>
<p align="center">PHP Hosting by <a href="http://www.webune.com">Webune.com</a> </p>
<p>
</BODY>
</HTML>
function clickable_link($text)
{
# this functions deserves credit to the fine folks at phpbb.com
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "1:", $text);
// pad it with a space so we can match things at the start of the 1st line.
$ret = ' ' . $text;
// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, comma, double quote or <
$ret = preg_replace("#(^|[n ])([w]+?://[w#$%&~/.-;:=,?@[]+]*)#is", "1<a href="2" target="_blank">2</a>", $ret);
// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// zzzz is optional.. will contain everything up to the first space, newline,
// comma, double quote or <.
$ret = preg_replace("#(^|[n ])((www|ftp).[w#$%&~/.-;:=,?@[]+]*)#is", "1<a href="http://2" target="_blank">2</a>", $ret);
// matches an email@domain type address at the start of a line, or after a space.
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
$ret = preg_replace("#(^|[n ])([a-z0-9&-_.]+?)@([w-]+.([w-.]+.)*[w]+)#i", "1<a href="mailto:2@3">2@3</a>", $ret);
// Remove our padding..
$ret = substr($ret, 1);
return $ret;
}
$text="www.webune.com";
?>
<HTML>
<TITLE>Making Text URLs Into Clicable Links Tutorial</TITLE>
<HEAD>
<style type="text/css">
<!--
.style2 {color: #0066FF}
-->
</style>
</HEAD>
<BODY>
<h1 align="center" class="style2">Making Text URLs Into Clicable Links Tutorial</h1>
<p>the clickable link is before function is: <strong><?php echo $text; ?></strong></p>
<p>this is the text after the <span class="style2">clickable_link_function</span>: <?php echo clickable_link($text); ?> </p>
<hr size="2" noshade>
<p> If you have benefited or learned from this short "Howto" tutorial, we would appreciate if you can provide a link to our http://www.webune.com. By linking to webune, you will make these tutorials more available to others who are looking for information like this.</p>
<p>Thank You</p>
<p>webune Team</p>
<p><a href="http://www.webune.com/forums"><< Go Back</a> </p>
<p align="center">PHP Hosting by <a href="http://www.webune.com">Webune.com</a> </p>
<p>
</BODY>
</HTML>
hope this helps
Apr 24, 2008 Reply Report abuse
©2011 Webune Forums - Wed Dec 21, 2011 2:42 am
Powered by: Webune Forums V3
Powered by: Webune Forums V3