Making links clickable from comments in php

Posted by neat on Stack Overflow See other posts from Stack Overflow or by neat
Published on 2012-11-30T04:34:54Z Indexed on 2012/11/30 5:03 UTC
Read the original article Hit count: 209

Filed under:
|
|
|

im trying to create functions that will give my chat clickable links.... here are the functions i've created

<?php
//makes links starting with http clickable
    function makehttpclickable($text){
        return preg_replace('!(((f|ht)tp://)[-a-zA-Z?-??-?()0-9@:%_+.~#?&;//=]+)!i', '<a href="$1">$1</a>', $text);
}
//makes links starting www. http clickable

function clickywww($www){
    return preg_replace('!((www)[-a-zA-Z?-??-?()0-9@:%_+.~#?&;//=]+)!i', '<a href="$1">$1</a>', $www);
}
/function that gives me an error!
function clickydotcom($noob){
    return preg_replace('!([-a-zA-Z?-??-?()0-9@:%_+.~#?&;//=]+)(\.com)!i'.'!([-a-zA-Z?-??-?()0-9@:%_+.~#?&;//=]+)(\.com)!f', '<a href="$1.com$f">$1.com</a>', $noob);
}

I've been getting an unkown modifier error. Warning: preg_replace() [function.preg-replace]: Unknown modifier '!' So Anyways any help would be nice on how i can make all types of links clickable

© Stack Overflow or respective owner

Related posts about php

Related posts about hyperlink