Edit report at http://bugs.php.net/bug.php?id=54103&edit=1
ID: 54103 Updated by: johan...@php.net Reported by: sam at bike-this dot com Summary: Cannot create an object reference from a variable with namespaces. -Status: Open +Status: Bogus Type: Feature/Change Request Package: Class/Object related Operating System: Windows PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php See http://php.net/manual/en/language.namespaces.dynamic.php Previous Comments: ------------------------------------------------------------------------ [2011-02-26 05:36:19] sam at bike-this dot com Description: ------------ When creating a new object reference with variables and namespaces (tested with aliasing namespaces [use namespace as alias] and not [\long\namespace\path]) and it fails in both scenarios. This works without the use of namespaces. This bug seems like an overlooked feature. Test script: --------------- # test.php <?php use Test as T; require "namespace_test.php"; $name = "MyClass"; $obj = new T\$name; ?> # namespace_test.php <?php namespace Test { class MyClass { function __construct() { echo "Testing!"; } } } ?> Expected result: ---------------- Testing! Actual result: -------------- Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING in test.php on line 5 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54103&edit=1