php-解析错误,期待``function(T_FUNCTION)''

时间:2017-02-08 11:31:52

标签: php laravel

我收到了这个错误,当我正在查看它的说法时

  

意外:错误沉默

这是我的代码。

我只是想制作类图。

class GetEntityLocation
{

    /**
     * @var  integer
     */
    @protected $Region_ID;
    /**
     * @var integer
     */
    @protected $Match_ID;


    /**
     * GetEntityLocation constructor.
     * @param integer $Region_ID
     * @param integer $Match_ID
     */

    public function __construct($Region_ID, $Match_ID)
    {
        $this->Region_ID = $Region_ID;
        $this->Match_ID = $Match_ID;
    }

    /**
     * @return integer
     */
    public function getRegionID() {
        return $this->Region_ID;
    }

}

1 个答案:

答案 0 :(得分:3)

您的代码无效。这是php has to say关于使用@符号的内容。

  

PHP支持一个错误控制操作符:at符号(@)。当在PHP中添加表达式之前,将忽略该表达式可能生成的任何错误消息。

这是php doc

中显示的示例
/* Intentional file error */
$my_file = @file ('non_existent_file') or
    die ("Failed opening file: error was '$php_errormsg'");

// this works for any expression, not just functions:
$value = @$cache[$key];
// will not issue a notice if the index $key doesn't exist.

因此,您可以使用@符号来抑制函数或表达式生成的错误。但是你不能用它来反对类属性的可见性。

而不是使用

@protected $Region_ID;
@protected $Match_ID;

使用

protected $Region_ID;
protected $Match_ID;

始终坚持最佳做法。

相关问题