What mechanism does WordPress use to keep constants from being redefined?

What mechanism does WordPress use to keep constants from being redefined?

None. Constants are not a WordPress feature, they’re a part of the PHP programming language.

Someone replied, “If the original coders don’t know that you can’t redefine a constant than why would you even trust any of their other code?”

I think this is them suggesting that if the authors don’t know that you cannot redefine a constant, then they might not be very good at PHP

That made me wonder, what mechanism in WordPress keeps themes/plugins/etc from redefining constants? I’m guessing that it has to do with the order in which code loads.

Once a constant is defined, it can’t be changed. PHP enforces this, otherwise constants would just be fancy variables that can change on a whim.

Generally, it’s considered poor practice to define those constants in plugins and themes. They’re intended for wp-config.php and should be set by the user. I would treat any plugin or theme that defines WP constants with great suspicion and skepticism.