PHP(5.3+)中的\(反斜杠)是做什么的?
在PHP中做什么?
例如,CSRF4PHP具有FALSE
, session_id
和Exception
:
public function __construct($timeout=300, $acceptGet=FALSE){
$this->timeout = $timeout;
if (session_id()) {
$this->acceptGet = (bool) $acceptGet;
} else {
throw new Exception('Could not find session id', 1);
}
}
(反斜杠)是PHP 5.3中的命名空间分隔符。
在函数开始之前的代表全局命名空间。
将它放在那里将确保所调用的函数来自全局名称空间,即使在当前名称空间中有相同名称的函数。
澄清可能的混淆:
反斜杠并不意味着类的继承 。
在下文中, Animal
, Dog
, Shepherd
不必是类,而只是命名空间。 意思是将名称组合在一起以避免命名冲突。
$myDog = new AnimalDogShepherdGermanShepherd();
领先指
Animal
在全球范围内宣布。
在5.3中用于名称空间。 有关命名空间和PHP的更多信息,请参见http://www.php.net/manual/en/language.namespaces.rationale.php。
上一篇: What does a \ (backslash) do in PHP (5.3+)?
下一篇: what does it mean?