示例: #/DB/MySql.class.php也就是DB文件夹下有MySql.class.php文件 namespace DB; class MySql { public function __construct() { var_dump(__FILE__); } } #/index.php namespace Home; use DB\MySql; $mysql = new MySql(); 报错 Fatal error: Class 'DB\MySql' not found in D:\l…
命名空间 避免类名重复,而产生错误. <?php require_once "useful/Outputter.php"; class Outputter { // output data private $name; public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } } $obj = new Outputt…