namespace
Estimated reading time: 1 minutewhat is namespace
namespace is a indicator for file . you can use specific file with specific namespace . namespace keyword is namespace
namespacelivetoplevel in thefile. (first declare)case-insensitive- sub directory with
\backslash
why use namespace
escapenamecollisionwith othersfile/folder/code- ability to use
large filename with aliasasveryshortyly.
<?php
namespace User\Info;
class profile {
function user() {
echo("function name isn't case-sensitive");
}
}
?>
how access namespace
- access by
usekeyword - alias wirh
askeyword
<?php
use User\Info;
use User\Info as client;
class Test{
}