c_shelswell Posted July 21, 2010 Share Posted July 21, 2010 Hi - I'm not sure if subject of this is really correct. What I mean is if I take one file and fill it full of all my: require('./class_user.php'); require('./class_session.php'); but don't actually call that class is this going to slow things down and use more memory or is the file effectively not read until i use $user = new user; and instantiate the class? Before i've just included the class at the top of the page that needs it just wondering if that's the best way Cheers Link to comment https://forums.phpfreaks.com/topic/208393-loading-a-class-page-but-not-instantiating-it-does-it-use-memory/ Share on other sites More sharing options...
Mchl Posted July 21, 2010 Share Posted July 21, 2010 The class is declared, it's static properties and methods are available, so yes it will consume both time and memory. See here for autoloading classes on need: http://php.net/manual/en/language.oop5.autoload.php Link to comment https://forums.phpfreaks.com/topic/208393-loading-a-class-page-but-not-instantiating-it-does-it-use-memory/#findComment-1088993 Share on other sites More sharing options...
c_shelswell Posted July 21, 2010 Author Share Posted July 21, 2010 ah right so autoload only loads the class when I instantiate it? great. Thanks Link to comment https://forums.phpfreaks.com/topic/208393-loading-a-class-page-but-not-instantiating-it-does-it-use-memory/#findComment-1088994 Share on other sites More sharing options...
Mchl Posted July 21, 2010 Share Posted July 21, 2010 That's right. Or when you access class' static properties/methods for the first time. Link to comment https://forums.phpfreaks.com/topic/208393-loading-a-class-page-but-not-instantiating-it-does-it-use-memory/#findComment-1088995 Share on other sites More sharing options...
c_shelswell Posted July 21, 2010 Author Share Posted July 21, 2010 nice one - thanks for your help Link to comment https://forums.phpfreaks.com/topic/208393-loading-a-class-page-but-not-instantiating-it-does-it-use-memory/#findComment-1088997 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.