Re: Initializing constants once, with code?
| From: | Mike Schinkel | Date: | Thu, 02 Jan 2020 23:40:46 +0000 |
| Subject: | Re: Initializing constants once, with code? | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-107964@lists.php.net to get a copy of this message | ||
> On Jan 2, 2020, at 6:14 PM, Bruce Weirdan <weirdan@gmail.com> wrote:
>
> There's also a fourth approach that does not involve any changes to
> PHP: autoload + eval.
> When PHP is looking for your class, in your autoload you load the
> values from config, generate the class source and eval() it.
Yes, I guess that would technically be possible.
But I think in this case — dynamically generated code, lack of type safety and inability to
version control and statically analyze the code — the proposed solution would be worse than the
fallback position of not using constants.
-Mike