语法错误,finally块无法识别 [英] syntax error, finally block is not recognized
问题描述
获取语法错误,意外的'{'
.当我删除时,最后阻止它工作.这是RESTful服务的GET方法.
Get syntax error, unexpected '{'
. When I delete, finally block it works. that is a GET method of RESTful service.
Route::resource('braining/firmware', 'Braining\FirmwareController',
['only' => ['index']]);
控制器
<?php
namespace App\Http\Controllers\Braining;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class FirmwareController extends Controller
{
public function index() {
try {
}
catch(Exception $e) {
}
finally {
}
}
}
推荐答案
将PHP升级到版本5.5
,问题将消失.
Upgrade PHP to version 5.5
and the problem will go away.
在PHP 5.5和更高版本中,也可以在或之后指定finally块. 而不是捕获块. finally块中的代码将始终为 在try和catch块之后执行,无论是否 已抛出异常,并且无法恢复正常执行.
In PHP 5.5 and later, a finally block may also be specified after or instead of catch blocks. Code within the finally block will always be executed after the try and catch blocks, regardless of whether an exception has been thrown, and before normal execution resumes.
来源: http://php.net/manual/zh_CN/language.exceptions.php#language.exceptions.finally
这篇关于语法错误,finally块无法识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!