Search code examples
phpclassclass-design

PHP class visibility


I am learning about PHP classes. I do have a bit of a C++ under my belt.

My goal here is to instantiate classes when a user loads my site and be able to use those classes while the users is on the site and then destroy.

Are there global classes in PHP? Where I could instantiate a class and have every users that hits my site get the values set in that class? Like page titles, default values, application defaults, default MySQL queries, etc?

I am not using a framework at this time, rather trying to learn myself.


Solution

  • There are some global classes within the SPL.

    However, class instances do not live longer than a single request, you have to instantiate/recreate them for every request.

    Hope this helps...