php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47001 autoload called by class_exists is different than called by new
Submitted: 2009-01-04 22:12 UTC Modified: 2009-01-04 22:46 UTC
From: pinochet dot pl at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3CVS-2009-01-04 (CVS) OS: Linux Ubuntu8.10 kernel: 2.6.24
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: pinochet dot pl at gmail dot com
New email:
PHP Version: OS:

 

 [2009-01-04 22:12 UTC] pinochet dot pl at gmail dot com
Description:
------------
There is namespace: jjroman_net when I call class_exist('\\jjroman_net\\MyClass'); the parameter of __autoload is `\jjroman_net\MyClass`
When I just type: new MyClass the parameter of __autoload is `jjroman_net\MyClass`

Reproduce code:
---------------
index1.php:
<?php
function __autoload($name) {
    var_dump($name);
    //require($name.'.php');
}
class_exists('\\jjroman_net\\MyClass');
?>
index2.php
<?php
function __autoload($name) {
    var_dump($name);
    //require($name.'.php');
}
$a = new \jjroman_net\MyClass.php;
?>

Expected result:
----------------
I expected unified way to call __autoload it's not matter if it will be \jjroman_net\MyClass or without the first slash but I don't like to push IF in autoload

Actual result:
--------------
index1.php: string(20) "\jjroman_net\MyClass"
index2.php: string(19) "jjroman_net\MyClass" 
(and fatal error ofcourse)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-04 22:46 UTC] johannes@php.net
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

class_exists() doesn't do any check of any kind... 
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 13 10:01:27 2025 UTC