74604

Priority between spl_autoload_register and extension's function?

I use composer to manage my dependencies and class loading. This tool uses spl_autoload_register function.

I would like to use a PHP's extension that provides some classes with same definition (name, namespacing, functionnalities) than others classes defined throught composer.

Which class will PHP load? The extension's one, or the autoload's one, or maybe the PHP's comportment is undefined?

Answer1:

PHP will use the extension's one. This is because autoloading will only happen if you are attempting to access a class which does not already exist. Extension functions and classes will exist after PHP's startup meaning before the code starts to run.

Recommend

  • Setting `cache_classes` to `false` fixes my bug. What to do next?
  • Android Theme Issue using AlertDialog.Builder
  • Substitute LHS of = in R
  • What is the usage of XsltArgumentList.AddParam's namespaceUri argument?
  • Remove index.php from URL (CodeIgniter)
  • CRON command with Yii
  • Get HTML Form Field Names
  • How can I make the glOrtho parallelepiped rotating?
  • Priority between spl_autoload_register and extension's function?
  • Get sku from each orders Woocommerce
  • PostgreSQL - select count(*) for rows where a condition holds
  • Exposing JAX-WS web service as spring bean
  • How do I exclude weekends in SQL?
  • How to force JPopupMenu to show title even if Look and Feel UI dictates otherwise?
  • Simple Factory with reflection C#
  • button in popup.html not working
  • VB.NET 2012 Property Set on Property Get
  • XNU incudes in Kext
  • How to know which Linq statement produced the SQL on hand during runtime?
  • Easiest way to get current unix timestamp via XSL
  • C#: Import/Export Settings into/from a File
  • Salesforce Different WSDL files and when to use
  • Subclassing QGraphicsItem prevents me from being able to use itemAt() on a QGraphicsScene/View
  • Why use database factory in asp.net mvc?
  • Can someone please explain to me in the most layman terms how to use EventArgs?
  • How to get current document uri in XSLT?
  • Why Encoding.ASCII != ASCIIEncoding.Default in C#?
  • one Local Olampyad Questions on Informatic in 2011
  • VSO Build — Response status code does not indicate success: 404 (Not Found)
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • Statically linking a C++ library to a C# process using CLI or any other way
  • Upload files with Ajax and Jquery
  • Build own AppleScript numerical error handling
  • Do I've to free mysql result after storing it?
  • A cron job substitute?
  • json Serialization in asp
  • KeystoneJS: Relationships in Admin UI not updating
  • python regex in pyparsing
  • Net Present Value in Excel for Grouped Recurring CF