2010-09-14 120 views
-1
function formatUpdate($tweet,$dt,$picture,$username) 
{ 
    if(is_string($dt)) $dt=strtotime($dt); 

    $tweet=htmlspecialchars(stripslashes($tweet)); 


     $at = "@" . $username; 




    return' 
    <li> 
    <a href="nano.com/' . $username . '"><img class="avatar" src="images/' . $picture . '" width="48" height="48" alt="avatar" /></a> 
    <div class="tweetTxt"> 
    <strong><a href="nano.com/' . $username . '">' . $username . '</a></strong> '. preg_replace('/((?:http|https|ftp):\/\/(?:[A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?[^\s\"\']+)/i','<a href="$1" rel="nofollow" target="blank">$1</a>',$tweet).' 
    <div class="date">'.relativeTime($dt).'</div> <a class ="reply" href="?replyto=' echo $at; '">reply</a> 
    </div> 
    <div class="clear"></div> 
    </li>'; 

} 
+0

在你的问题中的代码的格式非常简洁,最后一行是一个语法错误本身。我甚至不确定mattbasta的编辑是否做了任何改进。你能粘贴完整的代码吗? – BoltClock 2010-09-14 03:52:22

+0

这只是代码的一部分,我只是想向您展示代码片段以证明我的问题! – getaway 2010-09-14 03:53:30

+0

好吧,您的代码现在看起来的样子,您既不将该字符串分配给变量也不回应它。如果你的代码看起来像这样,就有问题。 – BoltClock 2010-09-14 03:55:21

回答

0

要将变量的值追加到你不用回显变量的字符串。

你有

href="?replyto=' echo $at; '">reply</a> 

将其更改为

href="?replyto='. $at .'">reply</a> 
+0

您的权利感谢,但问题它在页面上显示@username而不是“回复”链接?它的奇妙。我想我会做连接错误 – getaway 2010-09-14 04:13:08

1

螺栓是正确的。通常concat问题与代码,文字和结束引号/双引号混淆混淆。尝试使用heredoc来清理你的代码块。

例如,我会做以下操作来拯救我的眼睛代码盯着从疯狂救我的脑海里试图找到其中的语法错误的是(只有伪编码):

$at = "@$username"; 
$rt = relativeTime($dt); 

$out = <<<raw 
    <div class="date">$rt</div> 
    <a class ="reply" href="?replyto=$at">reply</a> 
raw; 

刚看看它看起来更简单呃?

了解heredoc这里是一个阅读参考。

裁判:http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc