Types and Variables Variables
Constants
•
bool define(string, expr [, case_insensitive])
•
defines a constant that is globally accessible within a script
•
string should be a string consisting of a PHP identifier
(preferably all upper-case)
The PHP identifier is the name of the constant
•
expr is an expression that should evaluate to a value of a scalar type
(In PHP 7, expr can also be an array)
•
case_insensitive is an optional boolean argument, indicating
whether the name of the constant is case-insensitive (default is FALSE)
•
returns TRUE on success or FALSE on failure
define ( " PI " ,3.14159);
define ( " SPEED_OF _ L I GH T " ,299792458 , true );
// PHP 7
define ( " ANIMALS " ,[ " bird " ," cat " ," dog " ]);
COMP519 Web Programming Lecture 19 Slide L19 – 23