PHP Constant
PHP constant is an identifier(name) for a simple value. The value does not change during the script. It starts with a letter or underscore not $ sign. The define()function is used to create a constant. Syntax:
define(name, value, case-insensitive);Example:
<!DOCTYPE html> <html> <body> <?php // case-sensitive constant name define("GREETING", "Welcome to PHP Tutorial"); echo GREETING; ?> </body> </html>Output Welcome to PHP Tutorial Constants are Global PHP constant is automatically global. It can be used for entire script.Let’s take an example. Example
<?php define("GREETING", "Welcome to PHP Tutorial"); functionmyTest() { echo GREETING; } myTest(); ?>