note 126086 deleted from language.oop5.autoload by crell

From: Date: Mon, 04 Apr 2022 16:05:45 +0000
Subject: note 126086 deleted from language.oop5.autoload by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218012@lists.php.net to get a copy of this message
Note Submitter: La Hong Hai ---- I use namespaces that match the files' directory paths (root excluded) so all i have to do with spl_autoload_register is: <?php spl_autoload_register(function (string $class): void { require "{$_SERVER['DOCUMENT_ROOT']}\{$class}.php"; } ); ?> No matter how complex your directory path is, there's no need for recursion or searching the whole project. *You might want to use str_replace() to replace "\" to "/" if you're using Linux (untested)

« previous php.notes (#218012) next »