php - What's the purpose of '\' when we create an object? -
this question has answer here:
- reference — symbol mean in php? 15 answers
what's purpose of using backslash \ when create object in php?
$iter = new \arrayiterator($arr);
it's used create new object of qualified class. say, you're code in namespace "namespace1":
namespace namespace1; $iter = new arrayiterator();
would resolved namespace1\arrayiterator();
and
$iter = new \arrayiterator();
would resolved arrayiterator();
see: http://php.net/manual/de/language.namespaces.basics.php more infos namespaces.
Comments
Post a Comment