# Proposal for 2 new magic constants

- Thread: https://externals.io/message/130993
- Original archive: https://news-web.php.net/php.internals/130993
- Started by php@s22.us on 2026-05-23T18:42:04+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #130993 — php@s22.us — 2026-05-23T18:42:04+00:00

URL: https://externals.io/message/130993#130993

Thanks for the feedback, Jordi.  I appreciate it.

A couple of thoughts upon reading your reply:

Unless I'm missing something, I don't see the problem of having PHP 
return that information, since it already does so.  E.g. __DIR__ will 
return:

/home/username/path/to/dir

so my proposal is not asking for anything new — just to return a partial 
string of the path already available from PHP.

Perhaps a magic constant would be the wrong way to do it, but in my 
thinking, it would fit right in with __FILE__, __DIR__, etc.

Marc

---

## #130995 — Jordi Kroon — 2026-05-23T18:57:14+00:00

URL: https://externals.io/message/130993#130995 · In reply to: #130993

> Unless I'm missing something, I don't see the problem of having PHP 
> return that information, since it already does so.  E.g. __DIR__ will 
> return:
> 
> /home/username/path/to/dir

This assumes your project code lives somewhere in a subfolder within 
`$HOME`. In many situations, that is not the case at all. For example, 
it could simply be `/app`. Or, as a result of a chroot, `/home/username` 
may not be exposed at all. Instead, `__DIR__` would simply return 
`/path/to/dir`.

> 
> Perhaps a magic constant would be the wrong way to do it, but in my 
> thinking, it would fit right in with __FILE__, __DIR__, etc.

If it were to fit in with __FILE__, then it should be a magic constant. 
But I do not think it fits there. It should be an environment variable 
because it belongs to the runtime environment.

-- 
Regards,

Jordi Kroon
