note 82087 added to language.oop5.autoload
| From: | richard at richard-sumilang dot com | Date: | Thu, 27 Mar 2008 09:11:32 +0000 |
| Subject: | note 82087 added to language.oop5.autoload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137623@lists.php.net to get a copy of this message | ||
[ >= php5.3]
If you are using namespaces and this is MyClass.php:
<?php
namespace com::richardsumilang::utils;
class MyClass{
// ... code ...
}
?>
And say we are using MyClass in another file like so...
<?php
use com::richardsumilang::utils as Utils;
$foo=new Utils::MyClass();
?>
And lastly if this was our __autoload method:
<?php
function __autoload($class){
echo "Trying to load: ", $class,"\n";
}
?>
That will echo "com::richardsumilang::util::MyClass" and not "Utils::MyClass".
It is very useful that it is passing the full name of the class and not the alias name you use so if
your classes followed your directory structure then you would be ok:
com::richardsumilang::utils::MyClass = com/richardsumilang/utils/MyClass.php
- Richard Sumilang
----
Server IP: 64.71.164.2
Probable Submitter: 24.24.191.132
----
Manual Page -- http://www.php.net/manual/en/language.oop5.autoload.php
Edit -- https://master.php.net/note/edit/82087
Del: integrated -- https://master.php.net/note/delete/82087/integrated
Del: useless -- https://master.php.net/note/delete/82087/useless
Del: bad code -- https://master.php.net/note/delete/82087/bad+code
Del: spam -- https://master.php.net/note/delete/82087/spam
Del: non-english -- https://master.php.net/note/delete/82087/non-english
Del: in docs -- https://master.php.net/note/delete/82087/in+docs
Del: other reasons-- https://master.php.net/note/delete/82087
Reject -- https://master.php.net/note/reject/82087
Search -- https://master.php.net/manage/user-notes.php