PHP 手册对Closure::bind()几乎没有解释,而且这个例子也很混乱。
这是网站上的代码示例:
class A {
private static $sfoo = 1;
private $ifoo = 2;
}
$cl1 = static function() {
return A::$sfoo;
};
$cl2 = function() {
return $this->ifoo;
};
$bcl1 = Closure::bind($cl1, null, 'A');
$bcl2 = Closure::bind($cl2, new A(), 'A');
echo $bcl1(), "\n";
echo $bcl2(), "\n";
Run Code Online (Sandbox Code Playgroud)
Closure::bind() 的参数是什么?
上面使用了 Null,甚至还使用了“new”关键字,这让我更加困惑。
我在PHP 文档中看到了这段代码:
try {
throw new ErrorException("Exception message", 0, E_USER_ERROR);
} catch(ErrorException $e) {
echo "This exception severity is: " . $e->getSeverity();
var_dump($e->getSeverity() === E_USER_ERROR);
}
Run Code Online (Sandbox Code Playgroud)
它继续:
This exception severity is: 256
bool(true)
Run Code Online (Sandbox Code Playgroud)
异常严重性是什么意思,我是否必须使用它?
我一直在尝试使用\n,\r并PHP_EOL在过去的两小时,没有人对我的工作有PHP我的Windows电脑上查看时页面.我在安装过程中做错了什么?
我可以使用,<br />,但我希望能够使用PHP_EOL.