1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| <?php
namespace a { class A { public $name = '陌花拟'; public function say() { $namespace = '命名空间:' . __NAMESPACE__; $className = '类名' . __CLASS__; $methodName = '方法名' . __METHOD__; return $namespace . '<br>' . $className . '<br>' . $methodName . '<br>' . $this->name; } } }
namespace b { class A { public $name = 'mohuani'; public function say() { $namespace = '命名空间:' . __NAMESPACE__; $className = '类名' . __CLASS__; $methodName = '方法名' . __METHOD__; $temp = (new \a\A)->name; return $namespace . '<br>' . $className . '<br>' . $methodName . '<br>' . $temp; } } }
namespace { echo (new a\A)->say(); echo '<hr>'; echo (new b\A)->say(); }
?>
|