실제로 제 질문은 매우 간단합니다. PHP에서는 require 또는 include로로드 될 파일에 네임 스페이스를 정의 할 수 있습니다. 예 :이 코드를 실행하면 index.php에의PHP 네임 스페이스는 include 나 require 후에 변경되지 않습니다.
내용
namespace test;
require('example.php');
die(__NAMESPACE__);
example.php의 내용
namespace example;
echo "hello world";
, 출력 때문에 네임 스페이스는하지 않습니다, "테스트"입니다 다른 네임 스페이스가있는 파일을 포함하면 변경됩니다.
하지만 그 이유를 말해 줄 수 있습니까? 파서를 어떻게 상상할 수 있습니까? 그것은처럼 보일 수 : PHP 파일에서
namespace test{}
namespace example{}
// and here it goes on with test, but why I didn´t said namespace test
namespace test{}
가능한 여러 파일 및 네임 스페이스 범위 (http://stackoverflow.com/questions/15239845/multiple-files-and-namespaces-scope) –