note 80670 added to language.oop5.autoload
| From: | muratyaman at gmail dot com | Date: | Mon, 28 Jan 2008 15:57:10 +0000 |
| Subject: | note 80670 added to language.oop5.autoload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135482@lists.php.net to get a copy of this message | ||
__autoload() function can be very useful to optimize your code esp. when you have so many classes.
Unlike class extensions, optional parameters with class restrictions may not load your class.
<?php
class bClass{
function fun($p1, aClass $p2=NULL){
//do something
}
}
//depending on the usage
$b = new bClass();
$b->fun('No!');//this will not load class file for aClass
$b->fun('Really?', new aClass('Yes!'));//this will
?>
So, it's very encouraging to use classes everywhere!
Even encapsulating your functions inside simple classes to use like static modules, will help a lot!
Let's say, you have <b>50k</b> lines of code inside <b>100</b>
classes/files.. If you need a simple task to do very quickly, you should not be loading all of those
files, except the ones you need.
Though, it may be dangerous on some cases regarding the dependencies, load order, etc. Carefully
design your classes.
----
Server IP: 194.145.210.3
Probable Submitter: 82.144.250.86
----
Manual Page -- http://www.php.net/manual/en/language.oop5.autoload.php
Edit -- https://master.php.net/note/edit/80670
Del: integrated -- https://master.php.net/note/delete/80670/integrated
Del: useless -- https://master.php.net/note/delete/80670/useless
Del: bad code -- https://master.php.net/note/delete/80670/bad+code
Del: spam -- https://master.php.net/note/delete/80670/spam
Del: non-english -- https://master.php.net/note/delete/80670/non-english
Del: in docs -- https://master.php.net/note/delete/80670/in+docs
Del: other reasons-- https://master.php.net/note/delete/80670
Reject -- https://master.php.net/note/reject/80670
Search -- https://master.php.net/manage/user-notes.php