2014-10-07 67 views
-2

我想弄清楚如何使用cakephp將我的圖像源顯示在圖像內。每當我嘗試使用$this->Html放置源時,它只會顯示空白文本。圖像源不能在蛋糕中工作PHP

這是我打電話給我的形象:

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

,這是它是如何顯示在

<img class="banner-image" src="" /> 

似乎是什麼問題?

+4

請首先檢查文檔:** HTTP://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper ::圖像** – ndm 2014-10-07 05:52:08

回答

1

嘗試

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

也許theme/banner.png不存在於app/webroot中?嘗試使用URL鏈接代碼。

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