首页 文章

无法从php数组正确显示图像路径

提问于
浏览
1

我试图显示像echo $ contentsArray [0]的html;在PHP中,但不显示图像 . 因为,img路径显示为 "<?=POST_IMG?>post/item/mypost/post_1.png" 而不是 "img/PostImg/post/item/mypost/post_1.png" . 我该如何解决这个问题 .

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

1 回答

  • 1

    那么你的代码中的连接有问题 . 你可以参考下面的代码,

    Note : 最好避免使用简写的php标签

    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
    

相关问题