Re: [RFC] Function autoloading through spl_autoload*
| From: | Ferenc Kovacs | Date: | Sun, 14 Aug 2011 12:59:44 +0000 |
| Subject: | Re: [RFC] Function autoloading through spl_autoload* | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-54577@lists.php.net to get a copy of this message | ||
On Fri, Aug 12, 2011 at 3:54 PM, Jan Dolecek <juzna.cz@gmail.com> wrote:
> Someone said that it won't be that easy, because functions are
> searched within a namespace first and when they don't exist there,
> then are called from global namespace.
>
> Example:
> <?php
> namespace example;
> echo substr('Test', 1, 1);
>
> When calling function substr, Zend engine first tries to find function
> example\substr. If such function doesn't exist, it tries just substr
> which is found and called. Thanks to this lookup, we don't need to
> escape all function calls with backslash prefix.
>
> <?php
> echo not_found(1);
> When trying to autoload a function, which one should be auto loaded?
> "example\not_found" or "not_found"?
first example\not_found then \not_found if necessary.
>
>
>
> Similar situation is with constants, because of BC a non-existing
> constant must result in string with the same value as constant's name.
> <?php
> var_dump(MY_CONSTANT); // string(11) "MY_CONSTANT"
>
> Some programmes rely on it (though it's not recommended) and calling
> autoloader everytime would add significant load to such apps.
>
the autoloader shouldn't affect this, if no const is found, then the
constname should be used.
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu