note 110008 added to function.spl-autoload-register

From: Date: Tue, 11 Sep 2012 10:50:25 +0000
Subject: note 110008 added to function.spl-autoload-register
Groups: php.notes 
Request: Send a blank email to php-notes+get-190621@lists.php.net to get a copy of this message
An example to allow autoloading classes with namespace: <?php define('MY_BASE_PATH', (string) (__DIR__ . '/')); // Set include path $path = (string) get_include_path(); $path .= (string) (PATH_SEPARATOR . MY_BASE_PATH . 'php_class/'); $path .= (string) (PATH_SEPARATOR . MY_BASE_PATH . 'php_global_class/'); // $path .= (string) (PATH_SEPARATOR . 'additional/path/'); set_include_path($path); spl_autoload_register(function ($className) { $className = (string) str_replace('\\', DIRECTORY_SEPARATOR, $className); include_once($className . '.class.php'); }); ?> ---- Server IP: 180.92.182.149 Probable Submitter: 124.244.171.10 ---- Manual Page -- http://www.php.net/manual/en/function.spl-autoload-register.php Edit -- https://master.php.net/note/edit/110008 Del: integrated -- https://master.php.net/note/delete/110008/integrated Del: useless -- https://master.php.net/note/delete/110008/useless Del: bad code -- https://master.php.net/note/delete/110008/bad+code Del: spam -- https://master.php.net/note/delete/110008/spam Del: non-english -- https://master.php.net/note/delete/110008/non-english Del: in docs -- https://master.php.net/note/delete/110008/in+docs Del: other reasons-- https://master.php.net/note/delete/110008 Reject -- https://master.php.net/note/reject/110008 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#190621) next »