PHP Constant and PHP Variables
· A constant is an identifier or a name.These
constant value remains the same during the execution of script.
· Constant are like variable except once the value is assigned to the constant it
remains the same throughout the script.
· Constant are case sensitive.
· Note:Unlike Variable constant are global
across the entire script.
· Unlike variable you do not need to define $
sign before the name of a constant.
· A constant name starts with underscore or
letter,followed by number letter or underscore.when you have defined the
constant ,it can never be changed.
Following is an example:
To create a php constant use define() function:
name:name of the
Value:value of the
whether it shoud be case-sensitive or not.By default it is false.
Contant are global and can be used anywhere in the
Variable means to store a value, such as text string
“Hello Everyone!” or the integer value 4.A variable can then be reused
throughout your code,instead of using the actual value over and over again.Here
are the most important things to know about about variables in php:
- A variable starts with the $ sign, followed by the name
- PHP variables should be alpha-numeric and
- Variable are case sensitive.($text and $Text both are two
- Variables with more than one word must be separated by