[英]How can I concatenate the following in Yii2?
I have the following on my view file which I need to display as an image. 我的视图文件上有以下内容,需要将其显示为图像。
<img src="<?php echo PATH; ?>web/images/ad_image/<?php echo $ads['ads_id']; ?>.png " width="790" height="100" />
My PATH
is Yii::$app->request->baseUrl
. 我的
PATH
是Yii::$app->request->baseUrl
。 This does not work so I thought of using Yii alias @web
and Html helpers like this: 这行不通,所以我想到了使用Yii别名
@web
和HTML帮助器,如下所示:
echo Html::img('@web/images/ad_image'.$ads['ads_id'].'.png', ['width' => 790, 'height' => 100]); ?>
That does not work too so I tried this and my image still does not show: 那也行不通,所以我尝试了一下,但是我的图像仍然没有显示:
$bf_ad = $ads['ads_id'];
echo Html::img('@web/images/ad_image'.$bf_ad.'.png', ['width' => 790, 'height' => 100]);
What is the way to display this when I am loading from an array $ads
which I get by foreach (Yii::$app->params['ads_details'] as $ads) {
? 当我从通过
foreach (Yii::$app->params['ads_details'] as $ads) {
获得的数组$ads
foreach (Yii::$app->params['ads_details'] as $ads) {
加载时,如何显示此内容?
Try 尝试
$bf_ad = $ads['ads_id'];
echo Html::img(Yii::getAlias('@web').'/images/as_image/'.$bf_ad.'.png', ['width' => 790, 'height' => 100]);
尝试这个:
echo Html::img(Yii::getAlias('@web').'/images/ad_image/'.$ads['ads_id'].'.png', ['width' => 790, 'height' => 100]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.