PHP Constants

Constants are PHP containers for values that remain constant and never change. They’re mostly used for data that is known well in advance and that is used, unchanged, in multiple places within your application. Good candidates for constants are debug and levels, version numbers, configuration flags, and formula.

Constants are defined using PHP’s define() function, which accept two arguments:
The name of the constant and its value. Constant names must follow the same rule as variable names with one exception: the $ prefix is not required for constant names.
Here’s an example of defining and using a constant in a script:

By convention, constant names are usually entirely uppercased; this is to enable their easy identification and differentiation from “regular” variables in a script.

Anuj Kumar

I'm Anuj kumar a web developer with 4+ year experience .I write blogs in my free time. I love to learn new technologies and share with others. I founded PHPGurukul in September 2015. The main aim of this website to is provide php , jquery , mysql , phpoops and other web development tutorials. I am trying best effort to make PHPGurukul useful for every single moment spend on this website. If you think this website is useful to visit please share with your friend and buddies.

Recommended Tutorials for you

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *