Liquid Fire Posted February 21, 2007 Share Posted February 21, 2007 I remember seeing somewhere where if they included just one file, this file would include the required file where a class object was crated. so like if class_foo.php was need to use Class foo, the one file, lets call is auto_include.php, would be included. then if you did: $bar = new Foo(); where creates an object of foo, the auto_include.php file had code in there that would automatically include the class_foo.php file. anyone know of anything like this becuase this would be so useful as i would only every to to only include 1 file and then i would not have to worry about remembering to include the proper files for my classes? Link to comment https://forums.phpfreaks.com/topic/39520-automatically-loading-a-class-file-when-class-is-called/ Share on other sites More sharing options...
Balmung-San Posted February 21, 2007 Share Posted February 21, 2007 You would use the __autoload() function. This only works with PHP5 though. http://us2.php.net/manual/en/language.oop5.autoload.php Link to comment https://forums.phpfreaks.com/topic/39520-automatically-loading-a-class-file-when-class-is-called/#findComment-190705 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.