How Do I Make My Text Clickable
how do i make my text clickable
how, do, i, make, my, text, clickable
How Do I Make My Text Clickable
Post Description: how do i make my text clickable
POST# 1296
Posted On: Thu Apr 24, 2008 6:48 pm
petruslima
Topic: How Do I Make My Text Clickable
i have a forums and i dont want my users to use html to i want it so that everytime they submit a link url i want my script to recognize it and make it into and clickable link on my website

is that hard to do with php?


Thu Apr 24, 2008 6:50 pm
1
Web Hosting Support
Reply #1967
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

<?

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 &quot;Howto&quot; 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">&lt;&lt; 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

What do you think?

* name:  

* email:  

* Please enter comments:


Receive Replies on my Comments
(An email will be sent to you when someone replies to your comments)

Add image to comments
yes no             upload
     
  1. How Do I Make My Text Clickable