PHP constants are name or identifier that can't be changed during the execution of the script. PHP constants can be defined as define ().
A valid constant name starts with a letter or underscore (no $ sign before the constant name).
Defining PHP Constant :
Let's see the Syntax of php constant using define()
define(name, value, case-insensitive)
- name: specifies the constant name
- value: specifies the constant value
- case-insensitive: Default value is false. It means it is case sensitive by default.
Example :1
<?php define("DATABASENAME", "MYSQL SERVER DB"); echo DATABASENAME; ?>
Output :
-----------------
MYSQL SERVER DB
Example : 2
<?php define("DATABASENAME", "MYSQL SERVER DB",false); echo DATABASENAME; ?>
Output :
-----------------
MYSQL SERVER DB
The example below creates a constant with a case-insensitive name:
Example : 1
<?php define("DATABASENAME", "MYSQL SERVER DB",true); echo databasename; ?>
Output :
-----------------
MYSQL SERVER DB
No comments:
Post a Comment