如何在 Yii2 中连接以下内容?

How can I concatenate the following in Yii2?

我的视图文件中有以下内容,我需要将其显示为图像。

<img src="<?php echo PATH; ?>web/images/ad_image/<?php echo $ads['ads_id']; ?>.png " width="790" height="100" />

我的 PATHYii::$app->request->baseUrl。这是行不通的,所以我想像这样使用 Yii 别名 @web 和 Html 助手:

    echo Html::img('@web/images/ad_image'.$ads['ads_id'].'.png', ['width' => 790, 'height' => 100]); ?>

这也行不通,所以我尝试了这个,但我的图像仍然没有显示:

    $bf_ad = $ads['ads_id'];
    echo Html::img('@web/images/ad_image'.$bf_ad.'.png', ['width' => 790, 'height' => 100]);

当我从 foreach (Yii::$app->params['ads_details'] as $ads) { 得到的数组 $ads 加载时,如何显示它?

尝试

$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]);