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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:30:33+00:00 2026-05-31T22:30:33+00:00

I read about the class autoloading in PHP, but till now I didn’t understand

  • 0

I read about the class autoloading in PHP, but till now I didn’t understand why we should use __autoload() method?

I read that

PHP doesn’t use
this method becuase it has the handy little include functions,
include_once and require_once, that prevent you from loading the same
file more than once, but unlike a compiled language, PHP re-evaluates
these expressions over and over during the evaluation period each time
a file containing one or more of these expressions is loaded into the
runtime in this site why we should use autoloading,

but I don’t understand what is the meaning of PHP re-evaluates in the above statement!!
why require-once don’t solve the problem of loading php file more than once?

  • 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-31T22:30:34+00:00Added an answer on May 31, 2026 at 10:30 pm

    The original article is more clear when you read it more widely (see below) :

    It simply says that __autoload() is smarter than include_once() because the function include_once() has to be coded explicitly when the class may be required, and also because this function needs to be processed each time it appears in order to know if the file given in argument is already loaded or not.

    The other function __autoload(), on the contrary, can be called only once for several classes you may need. And then PHP tryes to load the corresponding source file only when a class definition is missing.

    We can sum up this argumentation by saying: you need one include_once() for each Class/Function source, while only one __autoload() may be enough for a set of Class source having the same location rule.

    Snippet of the article:

    Why you should use an autoload function in PHP

    The loading of classes is something that managed languages like Java
    and C# don’t need to worry about, class loaders are built into the
    compiler.

     [...]
    

    PHP doesn’t use this method becuase it has the handy little include functions, include_once and require_once, that prevent you
    from loading the same file more than once, but unlike a compiled
    language, PHP re-evaluates these expressions over and over during the
    evaluation period each time a file containing one or more of these
    expressions is loaded into the runtime. That is where the Standard PHP
    Library (SPL), introduced in PHP 5, and the wonderful little _autoload
    function come in to enhance the speed and uniformity of your PHP code.

    __autoload is a magic function, that you define, that enables PHP to let you know when it doesn’t have a class loaded, but that class
    needs to be loaded.

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

Sidebar

Related Questions

I have read about pointers to class members, but I have never seen them
I've recently read about this and seen people using this class, but in pretty
I read about the Dispatcher class in .NET. But curiously the System.Windows.Threading namespace does
We have all read about or heard about the stack class, but many of
I read about django signals ( http://docs.djangoproject.com/en/dev/topics/signals/ ), but as far as I understand,
As a result of articles I read about the Option class which helps you
I have read about dynamically loading your class files when needed in a function
I've read about it on a message board - Random class isn't really random.
There are lots written about the ReaderWriterLockSlim class which allows multiple read and a
From what I've read about PHP HipHop – it serves the purpose of converting

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.