welcome to tutorialfamily

php constants

Php constants – It is like variable.

After define it cant be change.


php constants

Constant start with letter or underscore.

It cant be change during the script.

Use with define() function.

  • name:name of constant
  • value:value of constant
  • name:constant name should be case-insensitive. Default is false

constants



<!DOCTYPE html>
<html>
<head>
	<title>constants example</title>
</head>
<body>
   define(name, value, case-insensitive)
</body>
</html>

constants case sensitive



<!DOCTYPE html>
<html>
<head>
	<title>constants sensitive</title>
</head>
<body>
   <?php
    define("HELLO", "Welcome to tutorialfamily.com!");
    echo HELLO;
   ?>
</body>
</html>

constants case insensitive



<!DOCTYPE html>
<html>
<head>
	<title>constants insensitive</title>
</head>
<body>
   <?php
    define("HELLO", "Welcome to tutorialfamily.com!", true);
    echo hello;
   ?>
</body>
</html>

constants array



<!DOCTYPE html>
<html>
<head>
	<title>constants array</title>
</head>
<body>
   <?php
      define("cars", [
      "Toyota",
      "Oddi",
      "Hero"
     ]);
      echo cars[0];
   ?>
</body>
</html>

output

Our Content