Loading, please wait...

A to Z Full Forms and Acronyms

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

Jan 21, 2022 PHP, 1660 Views
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");

?>
A to Z Full Forms and Acronyms