note 115369 added to language.oop5.autoload
| From: | oliver dot strevel at gmail dot com | Date: | Mon, 14 Jul 2014 00:50:43 +0000 |
| Subject: | note 115369 added to language.oop5.autoload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199924@lists.php.net to get a copy of this message | ||
My autoloader function:
<?php
/**
* Funcion de autocarga de clases para php
* Se realiza la busqueda directamente sobre la raiz de la carpeta lib con el prefijo
'.class.php'
*/
function __autoload( $class_name )
{
$invalidChars = array(
'.', '\\', '/', ':', '*', '?',
'"', '<', '>', "'", '|'
);
$class_name = str_replace($invalidChars, '', $class_name);
$extension_prefix = '.class.php';
if( !@include_once $class_name . $extension_prefix )
{
$path = 'lib'; // In this dir the function will search
foreach( new DirectoryIterator($path) as $file )
{
if($file->isDot()) { continue; }
if($file->isDir())
{
$file = $path . DIRECTORY_SEPARATOR . $file->getFilename() . DIRECTORY_SEPARATOR .
$class_name . $extension_prefix;
if(file_exists($file)) {
include_once $file;
}
}
}
}
if (!class_exists($class_name, false) || !interface_exists($class_name, false)) {
// return || Some tracking error task..
}
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 189.217.143.85
----
Manual Page -- http://php.net/manual/en/language.oop5.autoload.php
Edit -- https://master.php.net/note/edit/115369
Del: integrated -- https://master.php.net/note/delete/115369/integrated
Del: useless -- https://master.php.net/note/delete/115369/useless
Del: bad code -- https://master.php.net/note/delete/115369/bad+code
Del: spam -- https://master.php.net/note/delete/115369/spam
Del: non-english -- https://master.php.net/note/delete/115369/non-english
Del: in docs -- https://master.php.net/note/delete/115369/in+docs
Del: other reasons-- https://master.php.net/note/delete/115369
Reject -- https://master.php.net/note/reject/115369
Search -- https://master.php.net/manage/user-notes.php