Certified PHP Developer Learning Resources Constants


As name describes, constants hold values that don’t get changed during the runtime of a script. Same naming rules apply for constants except that $ sign is not used when defining constants. To give an emphasis to constants, it’s a common practice to define constant names in upper-case.
1.define('SITE_URL', 'https://www.example.com');
2.echo SITE_URL; // Would print https://www.example.com

Once defined, a new value cannot be assigned to a constant.
1.define('SITE_URL', 'https://www.google.com');
2.echo SITE_URL; // Would still print https://www.example.com

 For Support