2015-11-06 152 views
0

****** PHP致命错误命名空间声明语句必须是第2行C:\ xampp \ htdocs \ yii2 \ advanced \ frontend \ models \ Employee.php脚本中的第一条语句******PHP致命错误

什么代码下面显示的代码是我的代码运行时我得到上述错误

<?php 
namespace frontend\models; 

use Yii; 

/** 
* This is the model class for table "employee". 
* 
* @property integer $Emp_id 
* @property string $Emp_Name 
* @property string $Emp_Gender 
* @property string $Emp_Designation 
* @property double $Emp_Sallary 
* 
* @property Empinfo[] $empinfos 
*/ 
class Employee extends \yii\db\ActiveRecord 
{ 
    /** 
* @inheritdoc 
*/ 
public static function tableName() 
{ 
    return 'employee'; 
} 

/** 
* @inheritdoc 
*/ 
public function rules() 
{ 
    return [ 
     [['Emp_id', 'Emp_Name', 'Emp_Gender', 'Emp_Designation', 'Emp_Sallary'], 'required'], 
     [['Emp_id'], 'integer'], 
     [['Emp_Sallary'], 'number'], 
     [['Emp_Name', 'Emp_Gender', 'Emp_Designation'], 'string', 'max' => 45] 
    ]; 
} 

/** 
* @inheritdoc 
*/ 
public function attributeLabels() 
{ 
    return [ 
     'Emp_id' => 'Emp ID', 
     'Emp_Name' => 'Emp Name', 
     'Emp_Gender' => 'Emp Gender', 
     'Emp_Designation' => 'Emp Designation', 
     'Emp_Sallary' => 'Emp Sallary', 
    ]; 
} 

/** 
* @return \yii\db\ActiveQuery 
*/ 
public function getEmpinfos() 
{ 
    return $this->hasMany(Empinfo::className(), ['EmpId' => 'Emp_id']); 
} 

}

+0

请建议答案 –

回答

0

Empinfo::className()没有命名空间

可能像

use app/models/Empinfo; 
use Yii; 

function rules(){} 

......