在官方手册上没有找的这种写法的意思?
namespace {    $test = 'a';}namespace {    if($test == 'a'){        //do something    }}
回复内容:                                                                                  在官方手册上没有找的这种写法的意思?
namespace {    $test = 'a';}namespace {    if($test == 'a'){        //do something    }}
可以看看,以前优化的时候,用过这个方式,将框架多个文件合并成一个。
手册地址是: http://php.net/manual/zh/language.namespaces.definitionmultiple.php
我本地自己试了一次,发现一个问题
namespace a{    class abc    {        private $test = 'a';        public function ceshi()        {            echo $this->test;        }    }}namespace {    $ceshi = new a\abc();    $ceshi->ceshi();}
和
namespace a;class abc{    private $test = 'a';    public function ceshi()    {        echo $this->test;    }}namespace b;class abc{    private $test = 'b';    public function ceshi()    {        echo $this->test;    }}use a;$ceshi = new a\abc();$ceshi->ceshi();
意义差不多 第一种是全局调用
   
 
   