Constant is an identifier with a simple value whose value cannot be changed during script running.
A valid Constant name begins with a letter and underscore (no $ sign before the constant name).
Note: Unlike variables, constants are automatically global across the entire script. PHP constant - constant Array - constant global
Syntax
define (name, value, case-sensitive)
Parameterts :
- name : Specifies the name of the constant
- value : Specifies the value of the constant
- case-sensitive : Specifies the wheteher the constant name should be case-insensitive. Default is false.
Example
define("GREETING", "Welcome to kumaratuljaiswal.in");
echo GREETING;
Welcome to kumaratuljaiswal.in!
Example
define("GREETING", "Welcome to kumaratuljaiswal.in", true);
echo GREETING;
Welcome to kumaratuljaiswal.in
PHP Constant Arrays
In PHP7, you can create an Array constant using the define() function.Example
"HackerBoY",
"Atultheahacker",
"Kumar"
]);
echo cars[0];
HackerBoY
Constants are Global
Constants are automatically global and can be used across the entire script.Example
function myTest() {
echo GREETING;
}
myTest();
Welcome to hackingtruth.in
Video on This Topic :- Soon
I hope you liked this post, then you should not forget to share this post at all.
Thank you so much :-)