2010-09-14 126 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