Course Content
PHP is an object-oriented scripting programming language that allows web developers to create dynamic and interactive web pages. PHP stands for Hypertext Preprocessor (PHP).
Control Statement
A control statement is a statement that determines whether other statements will be executed.
Private: PHP
About Lesson

Constants are PHP containers that remain constant and never change. Constants are used for data that is unchanged at multiple places within a program. Variables are temporary storage while Constants are permanent. Use Constants for values that remain fixed and referenced multiple times.


Rules for defining constant

PHP constants can be defined in 2 ways:

  • Using define() function
  • Using const keyword


Using define() function

define(name, value, case-insensitive)

name: Name of the constant

value: Value of the constant

case-insensitive: Whether a constant is case-insensitive, The default value is false.


Using const keyword

The const keyword defines constants at compile time. It is a language construct, not a function.

const MESSAGE = "Welcome to PHP";