Home  >  Article  >  php教程  >  Yii2.0 study notes: the first page Saying Hello

Yii2.0 study notes: the first page Saying Hello

WBOY
WBOYOriginal
2016-11-16 10:24:061217browse
Controller目录下创建TestController.php

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

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

Copy the following code to say.php

46d32f1990b68e4dcdc5ffa50c980a0e
f62bfd67e0b24503a85b3b91d1829d4e

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.

Statement:
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
Previous article:PHP_02 usage supplementNext article:PHP_02 usage supplement