Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace tf\users {}
- namespace tf\core {
- class collection {
- private $_cl;
- function __construct() { $this->_cl = get_class($this); }
- function get_cl() { return $this->_cl; }
- }
- class core {
- private $_cl;
- function register($name) {
- $from = 'tf\\core\\collection';
- $to = 'tf\\users\\' . $name;
- printf ("aliasing %s --> %s : %s <br/> \n", $from, $to, class_alias($from, $to)?'OK':'FAIl');
- $a = new $to ();
- $this->_cl = get_class($a);
- return $a;
- }
- function get_cl() { return $this->_cl; }
- }
- }
- namespace {
- use tf\core\core;
- $core = new core();
- $test = $core->register('test');
- printf("core: %s, result: %s, get_class: %s <br/>\n", $core->get_cl(), $test->get_cl(), get_class($test));
- }
- /*
- результат:
- aliasing tf\core\collection --> tf\users\test : OK
- core: tf\core\collection, result: tf\core\collection, get_class: tf\core\collection
- ожидал получить:
- tf\users\test
- */
Advertisement
Add Comment
Please, Sign In to add comment