Jump to content

loading a class page but not instantiating it - does it use memory?


c_shelswell

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.