图像源无法在cakePHP中工作

时间:2014-10-07 05:48:17

标签: php image cakephp src

我试图弄清楚如何使用cakephp让我的图像源显示在我的图像中。每当我尝试使用$this->Html来放置源时,它只显示一个空白文本。

这就是我调用图像的方式:

<img class="banner-image" src="<?php $this->Html->image('theme/banner.png', array('alt' => 'CakePHP', 'border' => '0')); ?>" />

这就是它在

中的显示方式
<img class="banner-image" src="" />

似乎是什么问题?

2 个答案:

答案 0 :(得分:4)

也许 theme / banner.png 在app / webroot中不存在?请使用URL链接试用此代码。

echo $this->Html->image("theme/banner.png", 
    array("alt" => "CakePHP",'url' => array('controller' => 'Student', 'action' => 'view', 6)
));

答案 1 :(得分:1)

尝试

 echo $this->Html->image('theme/banner.png', array('class' => 'banner-image'));