Re: Class names (with regard to autoload)
| From: | Stuart | Date: | Thu, 26 Feb 2009 21:43:43 +0000 |
| Subject: | Re: Class names (with regard to autoload) | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-43193@lists.php.net to get a copy of this message | ||
2009/2/26 Robin Burchell <viroteck@viroteck.net>
> Hi all,
>
> I've been playing around with autoload lately, and specifically using
> autoload to load classes which may be in subdirectories. I came up
> with the following test script:
>
> <?php
>
> function __autoload($sName)
> {
> echo "autoloading " . $sName . "\n";
> }
>
> $s = "Foo.Bar";
>
> $a = new $s();
> $b = new Foo.Bar();
> ?>
>
> The first line demonstrates what I'm after ("autoloading Foo.Bar"),
> and the second seems to give a bit of an odd/incorrect (in these
> circumstances) result(__autoload is invoked with "Foo").
>
> Is it possible to reconcile this behaviour to be a bit more
> consistant, and provide the behaviour I'm after?
>
> I'm willing to try provide a patch, if someone would be kind enough to
> direct me to the part(s) of the engine I'd need to look at.
>
The concatenation operator (.) is not valid in a class name. Use an
underscore and you'll be able to get the behaviour you want.
-Stuart
--
http://stut.net/