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

From: Date: Sat, 07 Jun 2008 00:28:20 +0000
Subject: #45197 [WFx->Csd]: new $classname(); dont works with namespaces
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-125558@lists.php.net to get a copy of this message
ID: 45197 User updated by: markus dot ast at hotmail dot de Reported By: markus dot ast at hotmail dot de -Status: Wont fix +Status: Closed Bug Type: Class/Object related Operating System: Vista x64 PHP Version: 5.3CVS-2008-06-06 (snap) New Comment: Okay, good to know, thanks! Previous Comments: ------------------------------------------------------------------------ [2008-06-06 23:59:00] colder@php.net 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. ------------------------------------------------------------------------ [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 (#125558) next »