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 7820147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:11:03+00:00 2026-06-02T07:11:03+00:00

Basically, I have the php class myclass located in root/lib/php/ and I want the

  • 0

Basically, I have the php class myclass located in root/lib/php/ and I want the classes the autoload from there, whenever I call them.

Now I am trying to do this in the main index.php file. How and where should I properly define spl_autoload_register so that I can use it for static class: myclass::mymethod()?

  • 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-02T07:11:06+00:00Added an answer on June 2, 2026 at 7:11 am

    Typically autoload coded is included in a config file or some other file that is included with each pageload and contains common code required for the site to run.

    Static calls to class methods is no different then instanciating a class and calling a method as far as autoload is concerned.

    An example:

    /*** nullify any existing autoloads ***/
    spl_autoload_register(null, false);
    
    /*** specify extensions that may be loaded ***/
    spl_autoload_extensions('.Class.php');
    
    /*** class Loader ***/
    define('BASE_APP_PATH', '/path/to/root/web/');
    function classLoader($class){
         $filename = $class . '.Class.php';
         $file = BASE_APP_PATH.'classes/' . $filename;
         if (file_exists($file)){
            include $file;
         }
    }
    
    /*** register the loader functions ***/
    spl_autoload_register('classLoader');
    

    You then can do this without explicitly requiring the class’ file:

    echo SomeClass::staticCall();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have a PHP class that that I want to test from the
So basically I have a PHP script that takes all the images from the
I have php generating html and I want to create layers. Basically I want
Basically I have a single page on my site that I want any php
Basically for a Facebook tab I have a PHP app and want Heroku to
I have derived a class from Exception , basically like so: class MyException extends
Ok, I need a little help. I have these two PHP classes class menu
I have a very large php maintenance script (basically it recreates thumbnails for an
Basically, we have an ASP website right now that I'm converting to PHP. We're
I have a class written in php that is supposed to find the labels

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.