How to use constants in PHP
A constant is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script (except for magic constants, which aren't actually constants). Constants are case-sensitive. By convention, constant identifiers are always uppercase.
<?php // global // can not change or undefined //start with a letter or underscore /** * Method 1: using const keyword */ const NUM = 15; echo NUM; // NUM = 23 !!!WRONG - can't change value /** * Method 2: using define */ define('KEY', "VAL", false); echo KEY; ?>
No comments: