note 92767 added to function.spl-autoload

From: Date: Sat, 08 Aug 2009 05:22:48 +0000
Subject: note 92767 added to function.spl-autoload
Groups: php.notes 
Request: Send a blank email to php-notes+get-159206@lists.php.net to get a copy of this message
Note, that the default autoload implementation is written in C land and is always slightly faster then your native PHP one. Here is a trick to use default implementation with any configuration: <?php // Your custom class dir define('CLASS_DIR', 'class/') // Add your class dir to include path set_include_path(get_include_path().PATH_SEPARATOR.CLASS_DIR); // You can use this trick to make autoloader look for commonly used "My.class.php" type filenames spl_autoload_extensions('.class.php'); // Use default autoload implementation spl_autoload_register(); ?> This also works with namespaces out of the box. So you can write code like "use My\Name\Object" and it will map to "class/My/Name/Object.class.php" file path! ---- Server IP: 82.135.230.5 Probable Submitter: 81.29.27.7 ---- Manual Page -- http://www.php.net/manual/en/function.spl-autoload.php Edit -- https://master.php.net/note/edit/92767 Del: integrated -- https://master.php.net/note/delete/92767/integrated Del: useless -- https://master.php.net/note/delete/92767/useless Del: bad code -- https://master.php.net/note/delete/92767/bad+code Del: spam -- https://master.php.net/note/delete/92767/spam Del: non-english -- https://master.php.net/note/delete/92767/non-english Del: in docs -- https://master.php.net/note/delete/92767/in+docs Del: other reasons-- https://master.php.net/note/delete/92767 Reject -- https://master.php.net/note/reject/92767 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#159206) next »