Re: Why is require still a function?
| From: | Tjerk Meesters | Date: | Mon, 23 Dec 2013 01:55:03 +0000 |
| Subject: | Re: Why is require still a function? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70845@lists.php.net to get a copy of this message | ||
Hi,
On Mon, Dec 23, 2013 at 8:28 AM, Kevin Ingwersen
<ingwie2000@googlemail.com>wrote:
> Hello there.
>
> I have seen an implementation of nodejs’ require function - but it needed
> to use a variable-function ($require(string $name)) instead, because
> ‚require()‘ is given.
>
> My questions are:
> - Why is require still also available as a function?
> - Why can’t re re-define something like that?
>
This is because
require is not a function but a language construct; the
token is defined in the language parser definition:
http://lxr.php.net/xref/PHP_5_6/Zend/zend_language_parser.y#62
Because of this, require is a reserved word unless exceptions are made in
the parser itself, so class require and function require(), even when
defined inside your own namespace will cause a parse error.
>
> Kind regards, and thanks! ^^
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
--
Tjerk