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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:17:19+00:00 2026-06-05T08:17:19+00:00

I’ve inherited a Class-based PHP site where every page of the site is its

  • 0

I’ve inherited a Class-based PHP site where every page of the site is its own Class. The index.php handles what page you view based on the p parameter, and then calls that specific Class. For example, the search page of the site is simply mysite.com/?p=search

One of the first lines in the index.php calls an Autoload.php file which does an include of every single Class-based page of the site. This means that no matter which page you are on, the script is loading every single other page/class.

My questions:

  1. There is NO connection between those pages/classes, so is it really necessary to load all of them on every pageload?
  2. Does it slow down the script having to include over 50 pages/classes on every pageload or is it negligible?
  3. If so, then shouldn’t I do an if-based check to determine which page/class I should load based on the p parameter and ONLY load that one rather than load every page on every pageload?
  4. Or is there some other potential downside of doing that that I’m not aware of?
  • 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-05T08:17:21+00:00Added an answer on June 5, 2026 at 8:17 am

    That’s a confusing name for the file, as autoloading is a mechanism in PHP that allows you to load classes as and when they are needed, a good solution when you have many classes and only a few will be needed for each execution.

    For example:

    function autoload($class_name) {
      $file = "classes/$class_name.php";
    
      // You could add some checks here (e.g. whether the file exists, whether the
      // class indeed exists after the file is loaded) to facilitate better errors,
      // of course this would marginally increase the time needed to load each class.
    
      require $file;
    }
    
    // Register the `autoload` function with PHP's autoload mechanism
    spl_autoload_register('autoload');
    
    // This will execute `autoload('Class')` (unless `Class` is already defined)
    $instance = new Class;
    

    So, to answer your questions:

    1. It is not necessary to load them all, however classes that are used must be available, either by loading them all together (current situation), loading them conditionally (if(p == 'whatever') require 'classes/whatever.php'), or by using autoloading.

    2. There is some delay whenever a file is included as the file must be parsed/executed. PHP is fairly fast but still, including files you do not need is a waste. If you’re using bytecode caching, the retrieved bytecode must still be executed.

    3. That is one avenue of improvement, autoloading presents a more dynamic alternative.

    4. Dependencies may be a problem if any of your page classes depend on another class, as your conditional loading could get very bloated.

    Also a little additional material regarding bytecode caching, if you’re using it:

    • PHP5 Frameworks: Autoloading and Opcode Caching
    • Do PHP opcode cache work with __autoload?

    The summary seems to be that, as long as you use include or require to load the file, bytecode caching will work as intended.

    • 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
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.