公告
财富商城
积分规则
提问
发文
2020-04-15 05:48发布
看我几分像从前
use level1\level2\level3;
Can someone explain with a simple demo ?
To clear up any confusion regarding different syntax use, namespaces support only two syntaxes, either bracketed or simple-combination both will work. I suggest if you use one over the other, be consistent.
<?php namespace my\stuff\nested { // <- bracketed syntax class foo {} } ?>
It creates a class foo inside of the nested namespace with bracketed syntax ({}), it is equivalent to
foo
nested
{}
<?php namespace my\stuff { // bracketed syntax but with a nested look namespace nested { class foo {} } } ?>
You can also use nested namespaces with simple-combination syntax (;)
;
<?php namespace mine; use ultra\long\ns\name; // <- simple-combination syntax $a = name\CONSTANT; name\func(); ?>
PHP: FAQ: things you need to know about namespaces
最多设置5个标签!
To clear up any confusion regarding different syntax use, namespaces support only two syntaxes, either bracketed or simple-combination both will work. I suggest if you use one over the other, be consistent.
It creates a class
foo
inside of thenested
namespace with bracketed syntax ({}
), it is equivalent toYou can also use nested namespaces with simple-combination syntax (
;
)PHP: FAQ: things you need to know about namespaces