Ancestors

Written by dseguy on 2024-12-26 at 15:12

A #PHP global constant redefinition is a simple warning.

A #PHP class constant redefinition is a full Fatal Error.

I am so used to the Fatal error, that I expected the global constant to behave the same. Shouldn't they?

[#]phptip #phptrick

https://php-tips.readthedocs.io/en/latest/tips/constant_redefinition.html

=> View attached media

=> More informations about this toot | More toots from dseguy@phpc.social

Written by Tobias van Beek on 2024-12-26 at 16:30

@dseguy I suspect it can be problematic if packages define global constance. (I don't know if there are packages who are doing that)

=> More informations about this toot | More toots from tvbeek@phpc.social

Toot

Written by dseguy on 2024-12-26 at 17:34

@tvbeek A quick search across 3100+ OSS source codes shows 902 (29%) of them using define(): even more of them use const, although for class constant too.

Then, 1370 uses defined() (44%): again, class and global, so actual might be lower.

So, that is roughly one out of 3 of us.

If it is not you, or me, who can it be? names! names! 😂

=> More informations about this toot | More toots from dseguy@phpc.social

Descendants

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113720326334157704
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
262.547655 milliseconds
Gemini-to-HTML Time
0.709243 milliseconds

This content has been proxied by September (ba2dc).