note 120156 added to language.oop5.decon

From: Date: Mon, 14 Nov 2016 04:12:36 +0000
Subject: note 120156 added to language.oop5.decon
Groups: php.notes 
Request: Send a blank email to php-notes+get-207089@lists.php.net to get a copy of this message
As of PHP 5.3 there are two ways to define constants: Either using the const keyword or using the define() function. const cannot be used to conditionally define constants. To define a global constant, it has to be used in the outermost scope: if (...) { const FOO = 'BAR'; // invalid } // but if (...) { define('FOO', 'BAR'); // valid } If you want to do that anyways? One common application is to check whether the constant is already defined: Do like this if (!defined('FOO')) { define('FOO', 'BAR'); } ---- Server IP: 72.52.91.14 Probable Submitter: 111.93.69.229 ---- Manual Page -- http://php.net/manual/en/language.oop5.decon.php Edit -- https://master.php.net/note/edit/120156 Del: integrated -- https://master.php.net/note/delete/120156/integrated Del: useless -- https://master.php.net/note/delete/120156/useless Del: bad code -- https://master.php.net/note/delete/120156/bad+code Del: spam -- https://master.php.net/note/delete/120156/spam Del: non-english -- https://master.php.net/note/delete/120156/non-english Del: in docs -- https://master.php.net/note/delete/120156/in+docs Del: other reasons-- https://master.php.net/note/delete/120156 Reject -- https://master.php.net/note/reject/120156 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#207089) next »