php-分析错误,应为“.”;函数(T_函数)"';
我得到了这个错误,当我查看ide时,它说 意外:错误沉默 这是我的密码 我只是想做一个类图php-分析错误,应为“.”;函数(T_函数)"';,php,laravel,Php,Laravel,我得到了这个错误,当我查看ide时,它说 意外:错误沉默 这是我的密码 我只是想做一个类图 class GetEntityLocation { /** * @var integer */ @protected $Region_ID; /** * @var integer */ @protected $Match_ID; /** * GetEntityLocation constructor.
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;
}
}
您的代码无效。这就是使用
@
符号的意义所在
PHP支持一个错误控制操作符:at符号(@)。在PHP中,在表达式前面加上前缀时,将忽略该表达式可能生成的任何错误消息
这是php文档中显示的示例
/* 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$Match\u ID代码>我认为这不是有效的php。为什么有人甚至需要抑制类属性声明的错误?
protected $Region_ID;
protected $Match_ID;