Home > php教程 > php手册 > body text

Yii2.0 study notes: the first page Saying Hello

WBOY
Release: 2016-11-16 10:24:06
Original
1216 people have browsed it
Controller目录下创建TestController.php
Copy after login

Copy the code below, yii is the same as tp, with full namespace

<?php

namespace app\controllers;

use yii\web\Controller;

class SiteController extends Controller
{
    // ...existing code...

    public function actionSay($message = 'Hello World')
    {
        return $this->render('say', ['message' => $message]);
    }
}
Copy after login

Create a test folder in the view folder and create say.php under the folder

Copy the following code to say.php

<?<span style="color: #000000;">php
use yii\helpers\Html;
</span>?>
<?= Html::encode($message) ?>
Copy after login

Visit your first page, url/basic/web/index.php?r=test%2Fsay, test is the controller and say is the method

Note, the header file comes with it, we will introduce how to modify it later.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template