a.php下有个命名空间
namespace foo;class classa{ public function foo_test(){ echo this is instance function; } }
在factory.php下
namespace factory;import('a.php');class classb{ public function createa(){ return \foo\classa::foo_test(); }}
为什么在factory.php下的createa方法会告诉我找不到 \foo\classa在factory.php下...它应该去a.php下找的啊,在php.5.5是可以通过的(找a.php),但是在5.6后就会找(factory.php)
请问这个如何解决啊。。。
回复内容: a.php下有个命名空间
namespace foo;class classa{ public function foo_test(){ echo this is instance function; } }
在factory.php下
namespace factory;import('a.php');class classb{ public function createa(){ return \foo\classa::foo_test(); }}
为什么在factory.php下的createa方法会告诉我找不到 \foo\classa在factory.php下...它应该去a.php下找的啊,在php.5.5是可以通过的(找a.php),但是在5.6后就会找(factory.php)
请问这个如何解决啊。。。
php中的引用有以下几种方式:
require(file_path);
require_once(file_path_;
include(file_path);
include_once(file_path);
use 'file_path';
具体区别自己去google
最后我想问,你这是写的什么东西???
php 好像真的没有 import() 这个内建方法...
按照 @lanffy 兄弟的改一下就好了...