PHP Constant

Agenda of this session

PHP PHP Constant | PHP Magic Constant

PHP Constant

A constant in PHP is a name or an identifier for a simple value. A constant value cannot change during the execution of the PHP script.

  • By default, a PHP constant is case-sensitive.
  • By convention, constant identifiers are always uppercase.
  • A constant name starts with a letter or underscore, followed by any number of letters, numbers, or underscore.
  • There is no need to write a dollar sign ($) before a constant, however one has to use a dollar sign before a variable.

PHP Magic Constant

PHP has nine predefined constants that change value depending on where they are used, and therefor they are called "magic constants". These magic constants are written with a double underscore at the start and the end, except for the ClassName::class constant.



We have our own LMS. SMARTLEARN is cloud based user-friendly Learning Management System. You will get 24 X 7 hours access by login with a unique username and password. The full course content has been uploaded in the LMS. Please Register with us. After registration you will get the login details.  Register Now