ID:               29480
 Updated by:       [EMAIL PROTECTED]
 Reported By:      roethlis at iam dot unibe dot ch
-Status:           Open
+Status:           Bogus
 Bug Type:         Feature/Change Request
 Operating System: irrelevant
 PHP Version:      5.0.0
 New Comment:

The make few scripts that include most important classes like Object
and Collection. For more advanced usage consider using
spl_autoload_register() and the advanced SPL's autoload mechanism.


Previous Comments:
------------------------------------------------------------------------

[2004-08-01 14:39:25] roethlis at iam dot unibe dot ch

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 this bug report at http://bugs.php.net/?id=29480&edit=1

Reply via email to