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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.