note 118833 added to language.namespaces.rules

From: Date: Fri, 12 Feb 2016 22:32:47 +0000
Subject: note 118833 added to language.namespaces.rules
Groups: php.notes 
Request: Send a blank email to php-notes+get-204933@lists.php.net to get a copy of this message
Namespaces may be case-insensitive, but autoloaders most often do. Do yourself a service, keep your cases consistent with file names, and don't overcomplicate autoloaders beyond necessity. Something like this should suffice for most times: <?php namespace org\example; function spl_autoload($className) { $file = new \SplFileInfo(__DIR__ . substr(strtr("$className.php", '\\', '/'), 11)); $path = $file->getRealPath(); if(empty($path)) { return false; } else { return include_once $path; } } \spl_autoload_register('\org\example\spl_autoload'); ?> ---- Server IP: 72.52.91.14 Probable Submitter: 77.50.25.68 ---- Manual Page -- http://php.net/manual/en/language.namespaces.rules.php Edit -- https://master.php.net/note/edit/118833 Del: integrated -- https://master.php.net/note/delete/118833/integrated Del: useless -- https://master.php.net/note/delete/118833/useless Del: bad code -- https://master.php.net/note/delete/118833/bad+code Del: spam -- https://master.php.net/note/delete/118833/spam Del: non-english -- https://master.php.net/note/delete/118833/non-english Del: in docs -- https://master.php.net/note/delete/118833/in+docs Del: other reasons-- https://master.php.net/note/delete/118833 Reject -- https://master.php.net/note/reject/118833 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204933) next »