Php 有效代码出现意外的文件结尾错误
我在第25行(即,Php 有效代码出现意外的文件结尾错误,php,yii,Php,Yii,我在第25行(即,])得到下面函数的以下错误 语法错误,意外的文件结尾 这是一个yii应用程序。代码似乎有效。我用一些在线验证器检查了文件中的整个代码,没有发现任何问题。但它在运行时会抛出一个错误 public function actionDashboard( $id, $recent_appointment_date = NULL ) { $this->layout = 'doctor'; $doc =
])得到下面函数的以下错误代码>
语法错误,意外的文件结尾
这是一个yii应用程序。代码似乎有效。我用一些在线验证器检查了文件中的整个代码,没有发现任何问题。但它在运行时会抛出一个错误
public function actionDashboard( $id, $recent_appointment_date = NULL )
{
$this->layout = 'doctor';
$doc = Doctors::find()->where( 'user_id=:id', [ ':id' => Yii::$app->session->get( 'user_id' ) ] )->one();
$reminder = new Remainder();
if ( $recent_appointment_date != NULL )
{
$model = PatientBooking::find()->where( 'booking_date=:date', [ 'date' => $recent_appointment_date ] )->andWhere( 'doctor_id=:id', [ 'id' => $id ] )->orderBy( 'booking_time' )->all();
}
else
{
$model = PatientBooking::find()->where( 'booking_date=:date', [ 'date' => date( 'Y-m-d' ) ] )->andWhere( 'doctor_id=:id', [ 'id' => $id, ] )->orderBy( 'booking_time' )->all();
}
$booking = new PatientBooking();
$booking->doctor_id = $id;
return $this->render( 'doc_view', [
'model' => $model,
'id' => $id,
'doc' => $doc,
'booking' => $booking,
'reminder' => $reminder,
] );
}
我想问题出在你的控制器文件中。可能是文件中的某些代码未正确关闭。检查所有函数和文件末尾的大括号 我认为错误“位于”视图文件中(不在控制器中),例如错误发生在渲染视图文件的行上。
例如,您可能使用tag这个代码块看起来很好,问题是整个代码中的某个地方我认为或者您的php版本不支持数组的[]
,请尝试使用旧的array()
syntaxI使用在线工具检查整个代码,然后自己手动检查每一行。未发现任何问题。这可能是项目中使用的其他一些文件的问题吗?我的php版本是5.5.22,短数组支持是从5.4开始的,我想是的,你必须将php版本更新到5.4。我已经用在线php代码验证程序检查了整个文件,没有发现任何问题。我在同一控制器中的其他一些函数也有同样的问题,还有另一个控制器。所有错误都发生在$this->render line。您的yii版本是什么?在这里放置一个完整的控制器。版本为2.0.3错误消息如下:PHP解析错误–yii\base\ErrorException语法错误,在/var/www/html/drr/frontend/controllers/DoctorsController.PHP–yii\base\controller::render()的第571行,查看文件的代码似乎也有效。找不到任何问题。我的服务器也支持短代码