static function checkArg($argName, $value)
{
if ($value === null) throw new \InvalidArgumentException("'$argName' must not be null");
if (!is_string($value)) throw new \InvalidArgumentException("'$argName' must be a string");
$error = self::findError($value);
if ($error !== null) throw new \InvalidArgumentException("'$argName'': bad path: $error: ".var_export($value, true));
}
通俗点解释就是 指定对象具体的类型。
在没有引入将类文件引入当前文件时,php无法知晓你需要使用的是什么类(相同命名空间的类文件除外),所以 为了防止 存在多个同名类文件,php需要你指定具体的类文件,带反斜杠其实就是(命名空间)路径的表示。
在没有引入将类文件引入当前文件时,php无法知晓你需要使用的是什么类(相同命名空间的类文件除外),所以 为了防止 存在多个同名类文件,php需要你指定具体的类文件,带反斜杠其实就是(命名空间)路径的表示。
温馨提示:答案为网友推荐,仅供参考
第1个回答 推荐于2017-11-29
因为使用了php的命名空间,演示代码如下:
// 创建命名空间Articlenamespace Article;
class Comment { }
// 创建命名空间MessageBoard
namespace MessageBoard;
class Comment { }
//调用当前空间(MessageBoard)的Comment类
$comment = new Comment();
//调用Article空间的Comment类
$article_comment = new \Article\Comment();本回答被提问者采纳
第2个回答 2020-10-23