Declaring constants in PHP

Declaring a constant in PHP is done via define method. This method takes two arguments. First one is a name of a constant, and second one is a value of that constant. Name of the variable needs to be enclosed in quotes.

Older way of declaring a constant is via using a keyword const in front of the variable that needs to be treated as a constant. A value of a constant cannot be changed at a later time. Constants add clarity to the code.

Comments

Popular posts from this blog

Absolute and relative path in HTML pages

Errors

goto PHP operator