note 120156 deleted from language.oop5.decon by cmb

From: Date: Mon, 14 Nov 2016 11:05:32 +0000
Subject: note 120156 deleted from language.oop5.decon by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207093@lists.php.net to get a copy of this message
Note Submitter: Jatin Roy (royjatin092 at gmail dot com) ---- 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'); }

« previous php.notes (#207093) next »