Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8816877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:43:16+00:00 2026-06-14T04:43:16+00:00

I know this may sound a little odd, but is it possible to create

  • 0

I know this may sound a little odd, but is it possible to create a superclass or global class which can be called from any page/class without the need to include/use?

I want to have an activity tracker and a custom error log on my site that records the activities and errors from the users but i pretty much need them on every page and every class. Rather than having to import them all the item, can you create one that is always available? Such as the core classes for PHP? (mysql_, ftp_, include_*, etc)

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:43:18+00:00Added an answer on June 14, 2026 at 4:43 am

    If you’re okay with including at least a single file, you could put an autoloader into an include and have that handle all of your loading for you. You can read in more detail about spl_autoload_register here.

    From the documentation, a sample setup could be:

    function my_autoloader($class) {
        include 'classes/' . $class . '.class.php';
    }
    spl_autoload_register('my_autoloader');
    

    This code would go into your file that’s included on every page. With it, you’ll be able to do the following without ever manually including the class file:

    $superClass = new SuperClass();
    

    Now, doing this assumes you have a file located at classes/SuperClass.class.php and it does, in fact, contain a class SuperClass { declaration (not required, but you’ll get an error if it doesn’t).

    You can always change the path defined in your autoloader function, as well as the file-naming schema. Also, you can use several different locations/logic or whatever is needed to suit your setup.

    For instance:

    function adv_autoloader($class) {
        if (file_exists('classes/' . $class . '.class.php') {
            require('classes/' . $class . '.class.php');
        } else if (file_exists('includes/' . $class . '.inc.php') {
            require('includes/' . $class . '.inc.php');
        } else {
            // can't locate the class
            throw new Exception('Class not found: ' . $class);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this may sound silly little bit, but there is no other way
I know this may sound too easy for many but I just can't figure
I know this may sound relatively basic question, but still wanted to ask. I
I know that my this question may sound pathetic to you but as a
It may sound very silly to people who know this but I am quite
I know this may sound easy for a lot of people, but I've tried
I know this may sound stupid, but does js files impede the building of
I know this question may sound silly, but it happened. I put some statements
This may sound stupid but how do I define a global variable in Go?
I know this may sound strange, but I want to retrieve the system default

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.