From:             roethlis at iam dot unibe dot ch
Operating system: irrelevant
PHP version:      5.0.0
PHP Bug Type:     Feature/Change Request
Bug description:  __autload() in classes

Description:
------------
It would be great, if one can use __autoload($class) also as a method in
classes, not only as a function in global scope. So __autoload should be
available in a class, like __get(), __set() or __call() is. It's often
needed that you can communicate with an object of another class inside
your current class, for that purpose, it's necessary that the class
definition of this other class is loaded, which could be achieved using
__autoload() inside a class. 

Because many classes need to have access to a general purpose class like
Collection or Object, you have to write a lot of require_once
"class.Any.php" at the top of many classes, because you never know, if Any
is already loaded or not. It would be much better, if you could put
require_once "class.Any.php" in the __autoload() method of this class, so
you can be sure, that require_once is only executed when it's really
necessary.

Sure, it would be possible to have __autoload() in global scope, but
because I have all related classes in the same directory, I could simply
say require_once "myClass.php", when __autoload sits directly in a class.
When it's in the global scope, maybe in another included file, I would
have to specify the path to myClass.php, which make it difficult to move
classes around in a large class system. 

kind regards,
Dave


-- 
Edit bug report at http://bugs.php.net/?id=29480&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29480&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29480&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29480&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29480&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29480&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29480&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29480&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29480&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29480&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29480&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29480&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29480&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29480&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29480&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29480&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29480&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29480&r=float

Reply via email to