我正在尝试在视图文件中呈现图像.我的代码如下:
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
//'photo',
[
'attribute'=>'photo',
'value'=>('<img src =' .'uploads/' . $model->photo . ' height="100" width="100"' . '>')
],
[
'attribute' => 'birth_date',
'format' => ['date', 'dd-MM-Y'],
],
'mobile',
],
]) ?>
Run Code Online (Sandbox Code Playgroud)
虽然下面的代码有效:
<?php echo ('<img src =' .'uploads/' . $model->photo .'>'); ?>
Run Code Online (Sandbox Code Playgroud)
谢谢.
我正在尝试学习yii 2.0,目前我正在使用basicyii 2.0的版本.第一步是配置网址.所以,按照指导,我启用了mod_rewrite,检查了使用phpinfo(),然后添加下面的行components中config/web.php:
‘urlManager’ => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'showScriptName' => false,
],
Run Code Online (Sandbox Code Playgroud)
现在我希望http://localhost/basic/web/index.php?r=site/test能够工作http://localhost/basic/web/index.php/site/test
但它需要我的index方法SiteController.实际上它正在采取所有网址index方法.之后的部分index.php并不重要.即使是错误的controllerId/actionId作品.可能是什么问题呢?
这是我的 config/web.php
<?php
$params = require(__DIR__ . '/params.php');
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) …Run Code Online (Sandbox Code Playgroud)