PHPverse 2025

Voting

: max(seven, four)?
(Example: nine)

The Note You're Voting On

povares at skippergroupe dot com
3 months ago
"const is defined at compile time" may not be true, depending on what you call "defining".

Although you can't define a const inside an if, like

if ($c === 'a') {
const c = a;
}
else {
const c = b;
}
# Results in a parse error

you can assign it a value depending on a conditionnal 'define' constant

$a = 1;

if ($a === 1) {
define('a', 'one');
}
else {
define('a', 'two');
}

const c = a;
# Valid, c equals "one"

https://onlinephp.io/c/b8227

<< Back to user notes page

To Top