首先是控制器,我这里命名为HelloController
存放位置在\controllers文件夹下
<?php
namespace app\controllers;
use yii\web\Controller;
class HelloController extends Controller{
public function actionIndex(){
$helloStr = "Hello World!sss";
$data = array();
$data['view_hellostr'] = $helloStr;
return $this->renderPartial('index',$data);
}
}
然后视图文件在views文件夹下新建一个文件夹。Hello
然后建index.php。就是视图文件,代码如下
<h1><?=$view_hellostr ?></h1>
<end>
转载请注明原文地址: https://ju.6miu.com/read-1294806.html