PHP致命错误

时间:2015-11-06 05:32:59

标签: iis-7 yii2-advanced-app php-5.6

****** PHP致命错误名称空间声明语句必须是第2行中C:\ xampp \ htdocs \ yii2 \ advanced \ frontend \ models \ Employee.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']);
}

}

1 个答案:

答案 0 :(得分:0)

您的Empinfo::className()未命名

可能类似

use app/models/Empinfo;
use Yii;

function rules(){}

...