How to check a constant is defined or not in PHP | PHP programs
Jan 20, 2022
PHP,
1231 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");
?>