#29072 [Opn->Csd]: stack of __autoload handlers

From: Date: Mon, 02 May 2005 09:47:25 +0000
Subject: #29072 [Opn->Csd]: stack of __autoload handlers
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-78510@lists.php.net to get a copy of this message
ID: 29072 Updated by: andrey@php.net Reported By: jasbarne at indiana dot edu -Status: Open +Status: Closed Bug Type: Feature/Change Request Operating System: * PHP Version: 5.0 New Comment: Try ext/spl's mechanism for stacking of autoload functions. For exampel spl_autoload_register() and spl_autoload_call(). Will be available with PHP 5.1.0+ Previous Comments: ------------------------------------------------------------------------ [2004-07-10 14:32:39] helly@php.net That occured to me also. But we cannot do anything before 5.0. Until then you probably need a master __autoload included by auto_prepend_file ini setting. This one would need to handle an array of handlers....in the other files you'd need to register your functions. ------------------------------------------------------------------------ [2004-07-09 09:26:46] jasbarne at indiana dot edu Description: ------------ I'm using the __autoload function to load my package's files. However, if I use another package and that has also implemented __autoload then PHP barfs Would it be possible to create a stack of __autoload functions? As an alternative, perhaps we could link __autoload methods to class definitions, and then check class definitions for __autoload functions whenever a class is not found. Reproduce code: --------------- <?php // Test1.php function __autoload() {} ?> <?php //Test2.php include_once 'Test1.php'; function __autoload() {} ?> Expected result: ---------------- When user tries to instanciate undefined classes the engine checks all __autoload() functions to try to load the class file. Actual result: -------------- Fatal error: Cannot redeclare __autoload() (previously declared in C:\Apache\Apache2\htdocs\DomTools\test.php:5) in C:\Apache\Apache2\htdocs\DomTools\autoload.php on line 7 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29072&edit=1

« previous php.bugs (#78510) next »