-1
正在返回的PHP函數內的if語句的正確語法是什麼。靜態輸出是我目前如何擁有它,但我想將其轉換爲動態輸出。正確的PHP語法的HTML返回函數
這是靜態輸出:
function get_html() {
$output = '';
$output.= '<div class="commentCount">2</div>';
return $output;
}
這是動態輸出:
function get_html() {
$output = '';
$output.= '<div class="commentCount">
<?php if ($extractor->isConnected()) {
// Comment Count
echo $extractor->commentCount("blog".$id);
}?></div>';
return $output;
}
get_html()'的輸出正在做什麼?如果它被回顯到頁面,「動態輸出」將不會按照您的想法進行。 – TZHX
這是什麼問題? – Elby
你不能在字符串中使用PHP開放標籤。嘗試[連接](http://php.net/manual/en/internals2.opcodes.concat.php)字符串 – prehfeldt