What's the purpose of using backslash \ when we create an object in PHP?
$iter = new \ArrayIterator($arr);
What's the purpose of using backslash \ when we create an object in PHP?
$iter = new \ArrayIterator($arr);
 
    
     
    
    It's used to create a new object of a fully qualified class. Say, you're code is in the namespace "Namespace1":
namespace Namespace1;
$iter = new ArrayIterator();
would be resolved as Namespace1\ArrayIterator(); and
$iter = new \ArrayIterator();
would be resolved as ArrayIterator();
See: http://php.net/manual/de/language.namespaces.basics.php for more infos about namespaces.
