PHP Constants

PHP Constants

Constants are same as variables but the value of constants cant be changed after they are defined. Constant name starts with a letter or underscore. Constant name declaration rules are same as a variable. But it doesn’t define with “$” sign. Constant is always global.

Syntex
define(name, value, case-sensitive)

Parameters:

  • name: name of the constant
  • value: the value of the constant
  • case-insensitive: whether the constant name should be case-insensitive. It can be only true or false. Default is false.
<?php
define("welcome", "Welcome to webcodeschool.com!");
echo welcome;
?>