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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 16:01:29 2024 UTC