note 130476 added to language.constants

From: Date: Thu, 11 Sep 2025 02:15:38 +0000
Subject: note 130476 added to language.constants
Groups: php.notes 
Request: Send a blank email to php-notes+get-222337@lists.php.net to get a copy of this message
To set constant using define() will not work with namespace unlike using const. Example: <?php namespace MyProject; const IS_IT_CONNECTED = true; // will be able to access via \MyProject\IS_IT_CONNECTED define('START_TIME', time());// will be able to access via START_TIME only, not be able to access via ---\MyProject\START_TIME--- ?> Call: <?php var_dump(\MyProject\IS_IT_CONNECTED);// true var_dump(START_TIME);// numbers var_dump(\MyProject\START_TIME);// Fatal error: Uncaught Error: Undefined constant... ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 184.22.228.70) ---- Manual Page -- https://php.net/manual/en/language.constants.php Edit -- https://main.php.net/note/edit/130476 Del: integrated -- https://main.php.net/note/delete/130476/integrated Del: useless -- https://main.php.net/note/delete/130476/useless Del: bad code -- https://main.php.net/note/delete/130476/bad+code Del: spam -- https://main.php.net/note/delete/130476/spam Del: non-english -- https://main.php.net/note/delete/130476/non-english Del: in docs -- https://main.php.net/note/delete/130476/in+docs Del: other reasons-- https://main.php.net/note/delete/130476 Reject -- https://main.php.net/note/reject/130476 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#222337) next »