Autoloading in PHP Classes

Asked

Viewed 54 times

2

What would be the Autoloading of PHP Classes?

I see people using __autoload and spl_autoload_register there is a difference?

What association exists between the autoloader of commiserate and the self-loading conventional?
Are these two functions being used under the cloths in the autoloader of commiserate?

  • 2

    1) Autoloading Classes is checking, loading a particular file on your system. It’s as if you’ve been using require or include automatically. Avoiding all that code with numerous require. The self-loading also prevents you from loading files without need. This is because when you are, in fact, using them, the function you set in spl_autoload_register will do so at the right time, without prejudice to the system.

  • 2

    2) Yes, there are differences between them. The main one is that spl_autoload_register allows multiple functions of autoload, already __autoload is limited to one. Another very important difference is that __autoload is deprecated in PHP 7.2+ 4) Is the function spl_autoload_register that the Composer uses for class loading.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.