Computer >> Computer tutorials >  >> Programming >> PHP

constant() function in PHP


The constant() function returns the value of a constant.

Syntax

constant(const)

Parameters

  • const − The name of the constant to check

Return

The constant() function returns the value of a constant and NULL if the constant is not defined.

Example

The following is an example that defines a constant.

<?php
   define("myConstant","This is it!");
   echo constant("myConstant");
?>

Output

The following is the output.

This is it!