Bug #52230 [Bgs]: namespace & __autoload clash
| From: | felipe@php.net | Date: | Fri, 02 Jul 2010 12:54:23 +0000 |
| Subject: | Bug #52230 [Bgs]: namespace & __autoload clash | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-152038@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52230&edit=1
ID: 52230
Updated by: felipe@php.net
Reported by: spawn at frostdrake dot tk
Summary: namespace & __autoload clash
Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: gentoo & ubuntu
PHP Version: 5.3.2
New Comment:
Errr, forgets. The fix was about the spl_autoload only. For custom
autoloader it must be done manually. As Johannes said above.
Previous Comments:
------------------------------------------------------------------------
[2010-07-02 14:47:06] felipe@php.net
See bug #51991
We already fixed this issue. The \ is automatically converted to / on
system where / is the dir separator.
------------------------------------------------------------------------
[2010-07-02 11:31:48] johannes@php.net
It tries to load Core\init.php. you have to translate this yourself to
Core/init.php - mind the \ vs. /.
------------------------------------------------------------------------
[2010-07-02 01:30:23] spawn at frostdrake dot tk
Description:
------------
when you use __autoload($var) it will get the class needed depending on
the file.
by using namespace and getting the class by a full path name
ex
new \class\name
__autload will then try to load classname
Test script:
---------------
/** index.php **/
function __autoload($var) {
require_once($var.'.php');
}
//It will try to load the file Coreinit.php and not Core/init.php;
new Core\init
/** Core/init.php **/
namespace Core;
class init{
function __construct(){
echo 'Bingo..!';
}
}
Expected result:
----------------
that autoload loads Core/init.php
Actual result:
--------------
autoload loads Coreinit.php
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52230&edit=1