Table of Contents

Php - Define (Global Constant)

About

See define

Example

define('MY_ENV', getenv('MY_ENV'));
defined('MY_ENV')
# Static
MY_ENV
# or Dynamic
constant('MY_' . 'ENV');

case-sensitivity

define("CONSTANT", "Hello world."); // The third parameter defaults to FALSE, meaning that the constant is case-sensitive. 
echo CONSTANT; // outputs "Hello world."
echo Constant; // outputs "Constant" and issues a notice.

define("GREETING", "Hello you.", true); // TRUE = case-insensitive. 
echo GREETING; // outputs "Hello you."
echo Greeting; // outputs "Hello you."