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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:18:03+00:00 2026-05-20T10:18:03+00:00

Would the second autoload method I have below be better performance? <?php // regular

  • 0

Would the second autoload method I have below be better performance?

<?php

// regular __autoload function
function __autoload( $name )
{
     include( $class . '.php' );

}


// SPL autoload
spl_autoload_register("MyClass::Autoloader");
class MyClass
{
    public static function Autoloader($class)
    {
        // list of classes and their location
        $classes = array();
        $classes['spooncookie'] = 'cookie/cookie.php';
        $classes['spoondatabase'] = 'database/database.php';
        $classes['spoondatagrid'] = 'datagrid/datagrid.php';
        $classes['spoondatagridcolumn'] = 'datagrid/column.php';
        $classes['ispoondatagridpaging'] = 'datagrid/paging.php';
        // ....list of all the other class files.......    
        if(isset($classes[$class])){
            include( $classes[$class] );
        }
    }

}

?>
  • 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-20T10:18:03+00:00Added an answer on May 20, 2026 at 10:18 am

    The best way to get an accurate idea of which will give the best performance for your own usage is to test each of them. As a general rule, different methods of autoloading will be optimal in different scenarios, factors include: how many files/classes you have in total, how deep the directory structure is, and how many classes you will load on average per request.
    The key point behind using an autoloader isn’t to make your code run more quickly, but to improve how quickly you can write the code in the first place.

    For production code I really would recommend going with a well used autoloader from a framework instead of rolling your own, at least to start with. and then maybe modifying it later if you know its the bottleneck and can be improved.

    As a side note, have you seen this?
    http://weierophinney.net/matthew/archives/245-Autoloading-Benchmarks.html

    EDIT:

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

Sidebar

Related Questions

I would like to be able to start a second script (either PHP or
I have a 10 second sound effect wave file. What I would like to
Are there differences between /\((.*)\)/ and /\(([^\)]*)\)/ ? In particular, would the second regular
I would like to fadeIn a node over one second. Then leave it on
How can I play audio (it would be like a 1 second sound) from
I would like to have access to the Seconds_Behind_Master field, (as returned by SHOW
I have a project where I would like to create two session cookies in
I have created two custome membership providers that I would like to add to
Which static class initializes first if we have one more static classes in our
Why would the second criterion in this WHERE clause be ignored? $old = time()

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.