note 100996 modified in function.spl-autoload-register by thiago
| From: | thiago@php.net | Date: | Fri, 19 Nov 2010 12:29:09 +0000 |
| Subject: | note 100996 modified in function.spl-autoload-register by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-174187@lists.php.net to get a copy of this message | ||
Note that if no parameter is provided, then the default implementation of
spl_autoload() will be registered and that by default it checks all include
paths to contain filenames built up by the lowercase class name
appended by the filename extensions .inc and .php.
If such implementation does not suit your needs you can define and
register autoload function that meets your needs.
<?php
// {{{ constants
/**
* Holds the path to the source files
*/
define('BASE_PATH',
dirname(__FILE__) . \DIRECTORY_SEPARATOR . '..'
. \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR);
// }}}
/**
* Define and register autoloader function
*/
if (false === \spl_autoload_register(function ($className) {
require \BASE_PATH . str_replace(
"\\", \DIRECTORY_SEPARATOR, $className
) . ".php";
})) :
throw new Exception("Unable to register autoload function.", 248);
endif;
?>
--was--
@Anonymous:
http://www.php.net/manual/en/function.spl-autoload-register.php#96804)
Note that if no parameter is provided, then the default implementation of
spl_autoload() will be registered and that by default it checks all include
paths to contain filenames built up by the lowercase class name
appended by the filename extensions .inc and .php.
If such implementation does not suit your needs you can define and
register autoload function that meets your needs.
// {{{ constants
/**
* Holds the path to the source files
*/
define('BASE_PATH',
dirname(__FILE__) . \DIRECTORY_SEPARATOR . '..'
. \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR);
// }}}
/**
* Define and register autoloader function
*/
if (false === \spl_autoload_register(function ($className) {
require \BASE_PATH . str_replace(
"\\", \DIRECTORY_SEPARATOR, $className
) . ".php";
})) :
throw new Exception("Unable to register autoload function.", 248);
endif;
http://php.net/manual/en/function.spl-autoload-register.php