我這裏創建一個可點擊的鏈接的功能:PHP使得點擊鏈接
function makeClickableLinks($text) {
$notIncludedonLink = preg_replace('/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '', $text); // removing not included on the link
$urlLink = str_replace($notIncludedonLink,'',$text);
$finalText = str_replace($urlLink,'<a href="'.$urlLink.'" target="_blank">'.$urlLink.'</a>',$text);
return $finalText;
}
,而不是返回簡單的可點擊的鏈接,但是:
http://docs.google.com/
它顯示:
<a href="http://docs.google.com/" target="_blank">http://docs.google.com/</a>
我嘗試使用htmlentities
,但它不起作用。
這裏有一個JS代碼,將數據發送到服務器:
function checkNewLink() {
var latestId = $("input[name=latestLink]").val();
$('.newReply').load("links/ajax.php?action=newreply&msgid=<?php echo $msgId; ?>&latestid=" + latestId);
}
setInterval("checkNewLink()", 200);
其中latestId
包含輸入鏈接。它將被髮送到ajax.php。每200毫秒,它會檢查是否有新的輸入鏈接。
這並不理解什麼是你想在這裏實現。請更詳細地解釋您的問題 –
「$ text」包含什麼內容? – Priyank
它運作良好。你怎麼了?你是否像'text/html'而不是'text/plain'那樣正確地設置你的輸出?我們可以看到完整的代碼嗎? –