PHP language article

Home >> PHP language >>

  PHP spl_autoload_register vs __autoload

This article will explain difference between spl_autoload_register vs __autoload.

__autoload is generally considered obsolete. It only allows for a single autoloader. Generally, you should only use __autoload if you're using a version of PHP without support for spl_autload_register.

spl_autoload_register allows several autoloaders to be registered which will be run through in turn until a match is found.

Note : the __autoload() function can also be used for autoloading classes and interfaces, its preferred to use the spl_autoload_register() function. This is because it is a more flexible alternative (enabling for any number of autoloaders to be specified in the application, such as third party libraries). For this reason, using __autoload() is discouraged and it may be deprecated in the future.

1. read more about PHP __autoload

2. read more about PHP spl_autoload_register


Nice explanation

Nice explanation, Actually I was something like that and finally I found it.

  1 year ago      Amit Kumar      

Write your comment now