I read an article about namespaces in PHP. But I don’t get what they are used for?
<?php
namespace MyProject {
// Regular PHP code goes here, anything goes!
function run()
{
echo 'Running from a namespace!';
}
}
I also read the PHP.net manual about it, but didn’t quite get it.
Consider your write your own class, lets called it
Foo. Someone else writes also a part of the project and he calls one of his classes alsoFoo.Namespaces solve this problem.
Example: