PHP Constant
PHP Constant :– A PHP constant is a value which can not be changed during the program execution.An many programming languages,the only difference comes when we declare it in php.
So many people get confused in variable and a constant programatically when we use these two terms in php. So only the difference is a variable name might get changed but a constant can not during the script execution.
PHP Constant | Decleration
To declare and initialising a constant following syntax works for php==>>>define(constant_name, value, case_sensitive=true);
Example
<?php $_name="sachin"; $_name="harish";//it works well as you can change variable value define("webtechnology","javascript",false); define("webtechnology","html",false);// error saying webtechnology is already defined on line 13. echo webtechnology; echo $_name; ?> |
Advertisements
Add Comment
📖 Read More
- 1. PHP Datatypes
- 2. PHP Operators
- 3. PHP Else if / Elseif
- 4. PHP Switch
- 5. PHP Variable Scope
- 6. PHP Static Keyword
- 7. PHP Global Keyword
- 8. PHP While Loop
- 9. PHP For Loop
- 10. PHP Functions