The namespace is declared using namespace keyword, which should be at the very beginning of the file. Example:
Example #1 Defining namespace
<?php
namespace MyProject::DB;
const CONNECT_OK = 1;
class Connection { /* ... */ }
function connect() { /* ... */ }
?>
Namespace can contain class, constant and function definitions, but no free code.
Namespace definition does the following:
Unqualified class name (i.e., name not containing ::) is resolved at runtime following this procedure:
Unqualified function name (i.e., name not containing ::) is looked up at runtime first in the current namespace and then in the global space.
Unqualified constant names are looked up first at current namespace and then among globally defined constants.