Namespace definition

The namespace is declared using namespace keyword, which should be at the very beginning of the file. Example:

Exemple 20.1. Defining namespace

<?php
    namespace MyProject
::DB;
    
    const 
CONNECT_OK 1;

    class 
Connection /* ... */ }
    
    function 
connect() { /* ... */  }
    
?>

Same namespace name can be used in multiple files.

Namespace can contain class, constant and function definitions, but no free code.

Namespace definition does the following:

See also the full name resolution rules.