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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:05:43+00:00 2026-05-26T03:05:43+00:00

I am interested in learning autoloading, but new to PHP. I am reading the

  • 0

I am interested in learning autoloading, but new to PHP.
I am reading the book “PHP in Action” which writes the autoload method like

function __autoload($className) {
 include_once __autoloadFilename($className);
}
function __autoloadFilename($className) {
 return str_replace('_','/',$className).".php";
}

I want to pack these methods in a class. will it be better to pack them in an abstract class?

Or in normal class and including it in index.php?

How effeciently I can use the autoloading feature?

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-05-26T03:05:44+00:00Added an answer on May 26, 2026 at 3:05 am

    Securing an autoloader, ensure:

    • That the file you try to load is actually a file. include is pretty much like eval. For example disallow url inclusion via the php configuration.
    • That the classname is actually a syntactically correct classname. Could be helpful to secure things 😉

    You can also white-list namespaces and/or classnames that are appropriate for your concrete autoloader.

    Create a class as an autoloader, you must not take the static way, you can just assign any callback with spl_autoload_register, so you can register multiple autoloaders.

    Some quickly written autoloader class stub:

    class MyAutoloader
    {
        public function __construct()
        {
            $this->register();
        }
        public function register()
        {
            spl_autoload_register(array($this,'autoload'));
        }
        public function autoload($classname)
        {
            if ($this->isInvalidClassName($classname)) return;
            $file = $this->getFileForClassName($classname);
            if ($this->isInalidFile($file)) return;
            require $file; // bail out fatally.
        }
        ...
    }
    
    $myAutoloader = new MyAutoloader();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a vc++ developer (but like Qt) interested in learning from open source
I'm completely new to programming on the Android platform but I'm interested in learning
I am interested in learning python but my Linux skills suck. I would like
I'm interested in learning Haskell on my own time (not through a course), but
I'm interested in learning Objective C for iPhone development. This is a topic which
I'm interested in learning more about design practices in PHP for Database Abstraction &
I'm very interested in learning about the new feature in HTML5 called web sockets.
I’m interested in learning which technique developers prefer to use to enforce uniqueness in
I don't know much about functional programming but am interested in learning Clojure. Are
I'm interested in learning Android development.... but if I install the latest 2.0 SDK,

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.