How to use Constant in PHP

In this article I will explain how Constant Function can be used in PHP.
  • 1594

constant() Function

This function returns the value of a constant.

Syntax

constant(constant)

Example

<html>
<body>
<?php
//define a constant
define("GREETING","Hello Swati! How are you today?");
echo constant("GREETING");
?>
</body>
</html>

Output

constant-php.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.