|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesHabbo (last revision 2015-05-22 17:13 UTC by gabrielbebe28 at outlook dot com dot br)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-01-12 22:52 UTC] court at epixa dot com
[2010-02-19 08:31 UTC] jani@php.net
[2010-03-03 01:15 UTC] felipe@php.net
[2010-03-03 01:16 UTC] felipe@php.net
-Status: Open
+Status: Closed
[2010-03-03 01:16 UTC] felipe@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 10:00:01 2025 UTC |
Description: ------------ When you instantiate a namespaced class, the expected behavior is for the fully qualified namespace with leading slash absent to be passed to your registered function. However, if you instantiate a namespaced class with a class name stored in a variable, the fully qualified namespace is not evaluated and the leading slash (if specified) is included. You'll have to run the reproduce code twice to see what I mean. Reproduce code: --------------- function loadClass($class) { die($class . PHP_EOL); } spl_autoload_register('loadClass'); $myClass = '\Fully\Qualified\ClassName'; // run this first: new \Fully\Qualified\ClassName(); // run this second: //new $myClass(); Expected result: ---------------- First run: Fully\Qualified\ClassName Second run: Fully\Qualified\ClassName Actual result: -------------- First run: Fully\Qualified\ClassName Second run: \Fully\Qualified\ClassName