PHP program to create a case in-sensitive constant using define() function

Here, we are going to learn how to create a case in-sensitive constant using define() function in PHP?
Submitted by Nidhi, on November 11, 2020

Here, we will create a case in-sensitive PI constant using the defined function.

The syntax of define() function,


Here, the first parameter specifies the name of the constant and the second parameter specifies the value of the constant and the flag is used for case insensitivity, if we pass TRUE for the flag then the name of the constant will be case insensitive.

Program/Source Code:

The source code to create a case in-sensitive constant using the define() function is given below. The given program is compiled and executed successfully.

//PHP program to create a constant
//using define() function.

define(PI, 3.14);

$radius = 5;

$area = PI * $radius * $radius;

print ("Area of circle: " . $area);


Area of circle: 78.5


In the above program, we created a case insensitive constant PI using the define() function that contains value 3.14. Then we created a local variable $radius initialized with 5. Then calculate the area of the circle and print the result on the console screen.

PHP Class & Object Programs »



Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.