PHP:意外的T_函数
我的网站上有一个错误: 解析错误:语法错误,第17行的/home/velosofy/public_html/blog/index.php中出现意外的T_函数 index.php(第17行):PHP:意外的T_函数,php,syntax,Php,Syntax,我的网站上有一个错误: 解析错误:语法错误,第17行的/home/velosofy/public_html/blog/index.php中出现意外的T_函数 index.php(第17行): get('/index',函数(){ $page=from($_GET,'page'); $page=$page?(int)$page:1; $posts=获取帖子($page); 如果(空($posts)| |$page$page, “posts”=>$posts, 'has_pagination'=>h
get('/index',函数(){
$page=from($_GET,'page');
$page=$page?(int)$page:1;
$posts=获取帖子($page);
如果(空($posts)| |$page<1){
//不存在的页面
没有找到();
}
渲染('main',数组(
“页面”=>$page,
“posts”=>$posts,
'has_pagination'=>has_pagination($page)
));
});
有人能告诉我如何修复此问题吗?查看您发布的代码,似乎错误发生在内联函数调用上 此语法仅在PHP5.3及更高版本中有效。我猜您正在尝试运行PHP5.2中的代码,这将给出您报告的错误
解决方案:升级到PHP的最新版本。您真的应该在问题中的此处发布代码,而不是让我们转到单独的站点阅读。将您的PHP更新到5.3或更高版本。好的,谢谢,我将尝试此功能
get('/index', function () {
$page = from($_GET, 'page');
$page = $page ? (int)$page : 1;
$posts = get_posts($page);
if(empty($posts) || $page < 1){
// a non-existing page
not_found();
}
render('main',array(
'page' => $page,
'posts' => $posts,
'has_pagination' => has_pagination($page)
));
});