When is a included file considered executed?
register_shutdown_function($callback[,$params])
Registers a callback to be executed after script execution finishes or exit() is called
Is the callback executed when the code inside the included file finishes or when the script that included it finishes?
I considered How exactly is a PHP script executed?
That question does not answer whether the interpreter compiles the files into one big file or execute them separately, neither in the presentation or the answers.
About origin(Thanks commenters).
In magento Varien_Autoload
class has a constructor:
public function __construct()
{
register_shutdown_function(array($this, 'destroy'));//<- this is what the question is about
$this->_isIncludePathDefined = defined('COMPILER_INCLUDE_PATH');
if (defined('COMPILER_COLLECT_PATH')) {
$this->_collectClasses = true;
$this->_collectPath = COMPILER_COLLECT_PATH;
}
self::registerScope(self::$_scope);
}
That file is included in Mage.php
I was wondering if the function destroy
was executed right after the class had finished being defined. After giving it some thought, you can see that the function would never get called anyway(class definition does not instantiate), but that doesn't reduce the meaning.