1
我試圖顯示HTML像echo $ contentsArray [0];在PHP中,但圖像不顯示。 因爲img路徑顯示爲"<?=POST_IMG?>post/item/mypost/post_1.png"
而不是 "img/PostImg/post/item/mypost/post_1.png"
。我應該如何解決這個問題。無法正確顯示圖像路徑從PHP陣列
define('POST_IMG', 'img/PostImg/');
$item1 = '<a href="#" target="_blank"> <div class="left">
<img src="<?=POST_IMG?>post/item/mypost/post_1.png">
</div></a>';
$contentsArray = array($item1, ...More
它是一個字符串到PHP所以做這樣的''
。你只需要在你的字符串中形成一個變量 –