views:

44

answers:

3
 function twitterify($ret) {
  $ret = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);
  $ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
  $ret = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $ret);
  $ret = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $ret);
return $ret;
}

I'm trying to get this function to autolink my links on my blog,

<?php  autolink(@solomonaleh); ?>

But I get a blank screen. Thank you.

+2  A: 

You need to quote your argument:

<?php  autolink('@solomonaleh'); ?>

Otherwise the @ is a syntax error. You may also need to actually call the name of the function you define - your function code defines a function named 'twitterify', but you call one named 'autolink' - which is it?

Amber
i still get a blank screen
getaway
its definately autolink, sorry i chnaged both of them, but they still dnt work!! :(((((
getaway
+1  A: 

You also need to echo it since it returns a string.

<?php echo autolink('@solomonaleh'); ?>
Swamp56
oh you already answered sorry!! thanks!!!
getaway
A: 

sorry guys i have the solution, its my mistake, the function deos work, its just that you have to echo the arguement to SEE it Stupid Me!!

$tweet = "hey, @twitter what are you doing";
 echo autolink($tweet);

thanks people!!!

getaway