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

  • Home
  • SEARCH
  • 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 3788298
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:58:36+00:00 2026-05-19T11:58:36+00:00

I’m new to classes, so sorry if this is a wicked noob question. JMC

  • 0

I’m new to classes, so sorry if this is a wicked noob question.

JMC is my main class. Other classes are named like JMC_files or JMC_array. I want to use autoload. Does the autoload function go inside my main class or outside of it? So for a visual, should I do this:

class JMC {
    function __autoload($className) {
        include_once($className.'.php');
    }
    protected function foo() { }
}

class JMC_files extends JMC (){
}

or this:

function __autoload($className) {
    include_once($className.'.php');
}

class JMC {
    protected function foo() { }
}

class JMC_files extends JMC (){
}
  • 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-05-19T11:58:37+00:00Added an answer on May 19, 2026 at 11:58 am

    __autoload() is the name of a magic function that is automatically called by default when you attempt to reference a class that doesn’t yet exist in userland. It’s a function, not a class method, so you define it like this:

    function __autoload($className) {
        include_once($className.'.php');
    }
    

    If you like, you may set your own autoload handler (can be a function or a class method) instead, by using spl_autoload_register(). For example, if you want to give your main JMC class a static autoload() method that handles autoloading of class files, you would do something like this:

    class JMC {
        public static function autoload($className) {
            include_once($className.'.php');
        }
    
        protected function foo() {}
    }
    
    spl_autoload_register('JMC::autoload');
    
    // By referencing this class, if it doesn't yet exist then JMC's autoload()
    // gets called and PHP will attempt to load JMC_files.php to look for this class
    $files = new JMC_files();
    $files->foo();
    

    Where you want to place your autoload function depends on you. Your main JMC class sounds like a reasonable place for it; my framework’s autoload method lives in the main class too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported

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.