php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #50594 method_exists() is invoking __autoload()
Submitted: 2009-12-28 16:49 UTC Modified: 2009-12-30 22:56 UTC
From: maros dot gajdosik at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.12 OS:
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: maros dot gajdosik at gmail dot com
New email:
PHP Version: OS:

 

 [2009-12-28 16:49 UTC] maros dot gajdosik at gmail dot com
Description:
------------
Function method_exists() is invoking __autoload(), which, in my opinion, 
is an unwanted behaviour. Sorry, if this has been posted already - tried 
to search for it without any results.

Reproduce code:
---------------
<?php // PHP file "my_class.php"
  class my_class{
    public $property = "I'm not a class name!";
  }
?>

<?php // PHP file #2
  function __autoload($class_name) {
    echo 'Loading: '.$class_name.'<br />';
    require_once $class_name.'.php';
  }
	
  $my_object = new my_class();
  method_exists($my_object-> property, 'method');
?>

Expected result:
----------------
Loading: my_class
Loading: I am not a class name!


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-29 11:41 UTC] jani@php.net
This is expected behaviour. Will need to be documented better.
 [2009-12-30 12:24 UTC] svn@php.net
Automatic comment from SVN on behalf of rquadling
Revision: http://svn.php.net/viewvc/?view=revision&revision=292800
Log: method_exists() and property-exists() both call __autoload if class is not known.
Fix #50594
 [2009-12-30 12:24 UTC] rquadling@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2009-12-30 22:56 UTC] maros dot gajdosik at gmail dot com
I am glad to help even a tiny bit.
 [2020-02-07 06:09 UTC] phpdocbot@php.net
Automatic comment on behalf of rquadling
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=2c808dca9397d9f187b039249a6c88202d105fde
Log: method_exists() and property-exists() both call __autoload if class is not known. Fix #50594
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC