|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-09-05 16:58 UTC] jiri dot brachtl at centrum dot cz
Description:
------------
__autoload() fails to load class, when its name is used in the first parameter of is_sublass_of().
Reproduce code:
---------------
function __autoload($className) {
require_once $className . ".php";
}
//Both ClassName1 and ClassName2 are defined in separate files
print_r(
is_sublass_of("ClassName1", "ClassName2")
);
Expected result:
----------------
0 or 1
Actual result:
--------------
//nothing, like void return type
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 01:00:01 2025 UTC |
The follow example was requested. This should reproduce the error: <?php function __autoload($classname) { require_once('include/'.$classname.'.php'); } // in include/foo.php class foo { private $myVar; private $myDerivedClass; function __construct() { $this->myDerivedClass = new Bar(); } function getAllVars() { $values = get_object_vars($this); foreach($values as $property => $value) { if(is_subclass_of($value, 'Foo')) die('is a subclass!'); } } } //in include/bar.php class Bar extends Foo { private $anotherValue function __construct() { $this->anotherValue = 'foobar'; } } $myclass = new Foo(); $myclass->getAllVars(); ?> this causes a fatal error where it cannot include 'test 1.php'.