One is declared at the top as first three lines under MyProject
referes to MyProject
namespace whereas other three under AnotherProject
refers to AnotherProject
namespace.
If at least one namespace is declared as the top, file will be correctly parsed (namespace will be switched dinamically)
Just to be more clear, you can even do that
<?php
namespace MyProject {
const CONNECT_OK = 1;
class Connection { /* ... */ }
function connect() { /* ... */ }
}
namespace AnotherProject {
const CONNECT_OK = 1;
class Connection { /* ... */ }
function connect() { /* ... */ }
}
?>
However is strongly not recommended to declare two namespaces inside same php script