note 100542 added to language.namespaces.rules

From: Date: Fri, 22 Oct 2010 08:04:19 +0000
Subject: note 100542 added to language.namespaces.rules
Groups: php.notes 
Request: Send a blank email to php-notes+get-173369@lists.php.net to get a copy of this message
As working with namespaces and using (custom or basic) autoload structure; magic function __autoload must be defined in global scope, not in a namespace, also not in another function or method. <?php namespace Glue { /** * Define your custom structure and algorithms * for autoloading in this class. */ class Import { public static function load ($classname) { echo 'Autoloading class '.$classname."\n"; require_once $classname.'.php'; } } } /** * Define function __autoload in global namespace. */ namespace { function __autoload ($classname) { \Glue\Import::load($classname); } } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 78.191.12.12 ---- Manual Page -- http://www.php.net/manual/en/language.namespaces.rules.php Edit -- https://master.php.net/note/edit/100542 Del: integrated -- https://master.php.net/note/delete/100542/integrated Del: useless -- https://master.php.net/note/delete/100542/useless Del: bad code -- https://master.php.net/note/delete/100542/bad+code Del: spam -- https://master.php.net/note/delete/100542/spam Del: non-english -- https://master.php.net/note/delete/100542/non-english Del: in docs -- https://master.php.net/note/delete/100542/in+docs Del: other reasons-- https://master.php.net/note/delete/100542 Reject -- https://master.php.net/note/reject/100542 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173369) next »