#45197 [Opn->WFx]: new $classname(); dont works with namespaces

From: Date: Fri, 06 Jun 2008 23:59:00 +0000
Subject: #45197 [Opn->WFx]: new $classname(); dont works with namespaces
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-125557@lists.php.net to get a copy of this message
ID: 45197 Updated by: colder@php.net Reported By: markus dot ast at hotmail dot de -Status: Open +Status: Wont fix Bug Type: Class/Object related Operating System: Vista x64 PHP Version: 5.3CVS-2008-06-06 (snap) New Comment: Dynamic class references require the fully qualified class name (with the namespace in it) because at runtime there is no information about the current namespace. Previous Comments: ------------------------------------------------------------------------ [2008-06-06 23:53:22] markus dot ast at hotmail dot de Description: ------------ first: sry for my english (I am german) Trying to dynamicly declarate a class in a namespace doesnt works. It doesn't searches in the current namespace, if this class is present. It just searches in the global namespace. Reproduce code: --------------- <?php namespace Level1::Level2; class Example { public function __construct() { echo 'works!'; } } $classname = 'Example'; new $classname(); ?> Expected result: ---------------- Fatal error: Class 'Example' not found in test.php on line 11 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45197&edit=1

« previous php.bugs (#125557) next »