Re: multiple namespace per file

From: Date: Tue, 11 Sep 2007 00:02:43 +0000
Subject: Re: multiple namespace per file
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-32226@lists.php.net to get a copy of this message
<?php namespace A; require 'somefile.php'; class AX{} namespace B; class BX{ } ?> is somefile.php also included in the B namespace since you cannot include it in global scope.
No, somefile.php does not automatically belong to either A or B, it can contain namespaces definition inside and thus belong to either A or B or neither, but it is parsed as entirely separate entity. I general once the file is done, everything is forgotten (what happens in the file, stays in the file ;). Also remember require is run-time so it can't influence namespaces since those are compile-time (in other words, when we parse namespaces we don't know what's in somefile.php, when we parse somefile.php we don't know namespaces in including file existed). -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com

« previous php.internals (#32226) next »