得到这个错误:
命名空间声明语句必须是脚本中的第一个语句
在这段代码的最开始:
namespace app'controllers;
use yii'web'Controller;
use app'models'users;
class UserController extends Controller
{
public function actionIndex()
{
echo "working on .....";
}
}
您可能会出现此错误,因为您在<?php
<?php
namespace app'controllers;
use yii'web'Controller;
use app'models'users;
class UserController extends Controller
{
public function actionIndex()
{
echo "working on .....";
}
}
直接删掉
<?php
namespace app'controllers;
use yii'web'Controller;
use app'models'users;
class UserController extends Controller
{
public function actionIndex()
{
echo "working on .....";
}
}
如果没有名称空间,您也会得到错误。要解决这个问题,请删除当前的PHP文件并重新创建它。这会解决问题的。