In plain English: Global constants defined with define() and class/interface/trait/enum constants should always be written in ALL_CAPS (uppercase letters separated by underscores).
Why it matters: Following consistent naming conventions makes code instantly recognizable. In PHP, constants do not change their value. By convention, uppercase names tell any developer reading the code: “This value is immutable and global/constant; it is not a regular variable.”
define('max_retries', 3);
class Config {
public const timeoutSeconds = 30;
}
define('MAX_RETRIES', 3);
class Config {
public const TIMEOUT_SECONDS = 30;
}
define().const FOO = ...).name == name.to_uppercase()).MAX_RETRIES, TIMEOUT_SECONDS, etc.).E0004 has no configuration options and is enabled by default.
Variables start with lowercase or camelCase ($userCount). Constants are always UPPER_CASE_WITH_UNDERSCORES.