Php - Define (Global Constant)

Card Puncher Data Processing

About

See define

Example

  • Define
define('MY_ENV', getenv('MY_ENV'));
  • Defined
defined('MY_ENV')
  • Get
# 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."





Discover More
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