In php offer a flexible way of storing data because you can change their values and the type of data they store at any time.
If however you want to work with a value that you do not want to alter throughout your php script's execution.
You can define Constanta.You must use PHP built in function define() to create a constant After you have done this ,
the constant cannot be changed.
To use the define()function you must place the name of the constant and the value you want to give it within the call's
parentheses.These values must be separated by a common like so
define ("CONSTANT_NAME",42,treu);
The value you want to set can only be a number or a string.
By convention the name of the constant should be in uppercase letters .
Constants are accessed with the constant name only.
No dollar symbol is required .
out put is wrong because constant is Case-insensitive.
Because we declared : define("name");
but we called
echo Name; So out put is wrong.
If you want to know about html beginners you can also visit our html tutorial
define ("CONSTANT_NAME",42,treu);
The value you want to set can only be a number or a string.
By convention the name of the constant should be in uppercase letters .
Constants are accessed with the constant name only.
No dollar symbol is required .
Constants have
Three Parameters.Name : Specifies the name of the constant.
value :Specifies the value of the constant.
Case-insensitive : constant name should be case-insensitive.Default is false.
Out put is : fakrul.
In php constant is also important as logical operatorOut put is :Notice: Use of undefined constant Name - assumed 'Name' in E:\xampp\htdocs\form\constent.php on line 2
out put is wrong because constant is Case-insensitive.
Because we declared : define("name");
but we called
echo Name; So out put is wrong.
Constants are Global
In php constants are automatically global .You can use php constant in your enter script for example you can try this code :Out put is : This is php constant tutorial .
Hope you enjoy This php tutorial .
Keep practicing and send your feedback in comment.If you want to know about html beginners you can also visit our html tutorial
Post a Comment