简体   繁体   English

Laravel PHP版本错误

[英]Laravel PHP Version Error

I am in a trouble with Laravel 5.1 version. 我对Laravel 5.1版本感到麻烦。 I have built it on Ubuntu Platform with PHP 5.5.9. 我已经在PHP 5.5.9的Ubuntu平台上构建了它。 Then I got the following error: 然后我得到以下错误:

 PHP Parse error:  syntax error, unexpected 'class' (T_CLASS), expecting ')'

And these are the codes which return the error: 这些是返回错误的代码:

 <?php
 interface foo {
 }

 class class_with_method_that_declares_anonymous_class
 {
     public function method()
     {
         $o = new class { public function foo() {} };
         $o = new class{public function foo(){}};
         $o = new class extends stdClass {};
         $o = new class extends stdClass {};
         $o = new class implements foo {};
     }
 }

Another one: 另一个:

 <?php
 class Test {
     public function methodOne() {
        $foo = new class {
            public function method_in_anonymous_class() {
                return true;
            }
        };

        return $foo->method_in_anonymous_class();
    }

    public function methodTwo() {
        return false;
    }
 }

I searched for the solution, then I was informed about the PHP version of Ubuntu. 我搜索了解决方案,然后得知Ubuntu的PHP版本。 Afterwards, I updated PHP version from 5.5.9 to 5.6.17. 之后,我将PHP版本从5.5.9更新到5.6.17。 But still I am getting the same error. 但是我仍然遇到相同的错误。 What is wrong in here? 这是怎么了

您不能在PHP的类方法内声明类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM