Reputation: 193
Im trying to display the html like echo $contentsArray[0]; in php, however the image is not displayed.
since, the img path is displayed like "<?=POST_IMG?>post/item/mypost/post_1.png"
instead of
"img/PostImg/post/item/mypost/post_1.png"
. How should I fix this problem.
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
Upvotes: 1
Views: 57
Reputation: 1092
Well you have problem with the concatenation inside your code. you can refer following code,
Note : it is better to avoid use of short-hand php tag
define('POST_IMG', 'img/PostImg/');
$contentsArray = array('<a href="#" target="_blank">
<div class="left">
<img src= "'.POST_IMG.'post/item/mypost/post_1.png">
</div>
</a>', ...More
Upvotes: 1