Dynamic class names and namespaces

From: Date: Sun, 21 Oct 2007 13:57:48 +0000
Subject: Dynamic class names and namespaces
Groups: php.internals 
Request: Send a blank email to internals+get-32902@lists.php.net to get a copy of this message
Hello, Using dynamic class names works fine without namespaces, but doesn't work at all with namespaces. Take this simple example: <?php namespace test; class Foo {} $class = "Foo"; $foo = new test::$class(); ?> Will produce the following message: Fatal error: Class 'test::test' not found in foo.php on line Y Now if Foo would have a static method and we want to use dynamic access for a static method, we get another error: <?php include 'foo.php'; $class = "Foo"; test::$class::test(); ?> Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in ... All tested with current 5.3 /Magnus -- Small things make base men proud. -- William Shakespeare, "Henry VI"

« previous php.internals (#32902) next »