PHP Constants


php PHP Constants PHP Start

PHP Constants and its application

Constants are used to to declare the default or constant information that can be used in the program. To create the constant we use the define() function.

Syntax of Constant

define(name, value, case-insensitive)

Define function parameters:

• name: The name of the constant. • value: The value or information that we want to store into the constant. • case-insensitive: Here we will mention the name of constant is case sensitive or not.It may be true or false The default value of the case-insensitive is false. It means we can pass two parameters and third parameter is optional. ⇨ true: The case-sensitive is now followed. ⇨ false: The case-sensitive is now ignored.

Creating a constant with case-sensitive state ON

<?php define("LOGINSUCCESS", "You have successfully Logged ! ","true"); echo LOGINSUCCESS; ?>

Creating a constant with case-sensitive state OFF

<?php define("LOGINSUCCESS", "You have successfully Logged ! ","false"); echo LoginSuccess; ?>
php PHP Start Chapter Next »