note 130014 added to language.constants.syntax

From: Date: Sat, 08 Feb 2025 11:45:26 +0000
Subject: note 130014 added to language.constants.syntax
Groups: php.notes 
Request: Send a blank email to php-notes+get-221834@lists.php.net to get a copy of this message
"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 ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 185.4.63.193) ---- Manual Page -- https://php.net/manual/en/language.constants.syntax.php Edit -- https://main.php.net/note/edit/130014 Del: integrated -- https://main.php.net/note/delete/130014/integrated Del: useless -- https://main.php.net/note/delete/130014/useless Del: bad code -- https://main.php.net/note/delete/130014/bad+code Del: spam -- https://main.php.net/note/delete/130014/spam Del: non-english -- https://main.php.net/note/delete/130014/non-english Del: in docs -- https://main.php.net/note/delete/130014/in+docs Del: other reasons-- https://main.php.net/note/delete/130014 Reject -- https://main.php.net/note/reject/130014 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221834) next »