Laravel 4 syntax error out-of-the-box

一世执手 提交于 2019-12-07 03:34:04

问题


I just installed Laravel 4 (Illuminate) and as I opened the index.php file in a browser, I was met with this error:

Parse error: syntax error, unexpected 'yield' (T_YIELD), expecting identifier (T_STRING) in /www/Laravel4/vendor/illuminate/view/src/Illuminate/View/Environment.php on line 339

I have fixed the permissions for the meta folder, and installed all the dependencies through Composer. I am running PHP version 5.5.0alpha2 on OSX 10.8.2.


回答1:


That's because yield became a language construct in PHP 5.5 (used in Generators) - but someone decided that it's a good idea to use this short word to name a function:

public function yield($section)
{
  return isset($this->sections[$section]) ? $this->sections[$section] : '';
}

Downgrade to PHP 5.4 (after all, it's the current mainstream version, 5.5 is not even in beta yet) and it should work fine.



来源:https://stackoverflow.com/questions/13990693/laravel-4-syntax-error-out-of-the-box

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!