技术&日志

yii-入门资料

yii-2

控制器与URL

controler\ 目录下存放控制器

<?php
namespace app\controllers;

use yii\web\Controller;


class TestController extends Controller
{
public function actionIndex()
{
echo 'me create Controller success!';
}
public function actionUserIndex()
{
echo '方法名是用大写区分的';
}
}

访问自己创建的控制器

URL: http://{{域名}}/index.php?r=test/index :: 不能大写

URL:http://{{域名}}/index.php?r=test/user-index :: 使用-分隔