Re: Automatically execute Closures returned from primary script
| From: | Alex Pătrănescu | Date: | Wed, 23 Sep 2026 22:47:00 +0000 |
| Subject: | Re: Automatically execute Closures returned from primary script | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-132613@lists.php.net to get a copy of this message | ||
On Wed, Sep 23, 2026, 15:52 Tim Düsterhus <tim@bastelstu.be> wrote:
>
> > Another possible solution, that I didn't yet evaluate, might be
> > defining a magic constant
__MAIN__ that is equivalent to
> > __FILE__
> > of the script that is executed first.
>
> … defining a __MAIN__ constant, which should hopefully have much fewer
> design considerations and might also benefit PHP applications that don't
> leverage the front-controller approach to protect internal files from
> direct access (e.g. as a native variant of phpBB’s IN_PHPBB constant).
>
I think already this would work with
realpath($_SERVER['SCRIPT_FILENAME'])
--
Alex