PHP

How to check a constant is defined or not in PHP | PHP programs

How to check a constant is defined or not in PHP | PHP programs

How to check a constant is defined or not in PHP | PHP programs

We will check a constant is defined or not using the defined() function. The defined() function returns true if the given constant is defined otherwise it returns false.

 

<?php

define(PI,3.14);
    
if(defined("PI")==true)

	print("Constant is defined");

else

	print("Constant is not defined");

?>
TutorialsLink Curator

This is an official account managed by the team TutorialsLink Community