Php - Define (Global Constant)

Card Puncher Data Processing


See define


  • Define
define('MY_ENV', getenv('MY_ENV'));
  • Defined
  • Get
# Static
# or Dynamic
constant('MY_' . 'ENV');


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."

Recommended Pages
Card Puncher Data Processing
Php - Constant

in PHP See Class ConstantsClass Constants differ from normal static variables in that you don't use the $ symbol to declare or use them. Abstract static method With reflection and the...

Share this page:
Follow us:
Task Runner