91-9990449935 0120-4256464 |
PHP ConstantsPHP constants are name or identifier that can't be changed during the execution of the script. PHP constants can be defined by 2 ways:
PHP constants follow the same PHP variable rules. For example, it can be started with letter or underscore only. Conventionally, PHP constants should be defined in uppercase letters. PHP constant: define()Let's see the syntax of define() function in PHP.
Let's see the example to define PHP constant using define(). File: constant1.phpOutput: Hello trainingtrains PHP Output: Hello trainingtrains PHPHello trainingtrains PHP Output: Hello trainingtrains PHP Notice: Use of undefined constant message - assumed 'message' in C:\wamp\www\vconstant3.php on line 4 message PHP constant: const keywordThe const keyword defines constants at compile time. It is a language construct not a function. It is bit faster than define(). It is always case sensitive. File: constant4.phpOutput: Hello const by trainingtrains PHP
Next TopicPHP Data Types
|