Some of the URLs this script can handle:
- http://www.google.com
- https://github.com/pda/pheanstalk/
- http://www.google.com/search?client=ubuntu&channel=fs&q=search+this&ie=utf-8&oe=utf-8.php
/**
* @param String $s
* @return String
*/
public static function markupUrls($s) {
return preg_replace('@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '<a href="$1" target="_blank">$1</a>', $s);
}
* @param String $s
* @return String
*/
public static function markupUrls($s) {
return preg_replace('@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '<a href="$1" target="_blank">$1</a>', $s);
}
Related posts:
- How To Increase PHP Session Timeout
- How to get Visitor's IP Address using PHP
- How to test or check if MOD_REWRITE is enabled
2 comments :
can I use this for Blogspot as well?
Not sure if you could use that in Blogspot. Perhaps look for a Javascript counterpart of this. They're more welcome inside Blogspot themes.
Post a Comment
Hi there! Please leave your message here. Also, I may not be able to respond to your query right away. So please bear with me. Thanks. :)