The PHP defined() function is an inbuilt function in PHP which checks whether a constant is exists or not, in other words, defined or not.
Parameter: This function accepts a single parameter as mentioned above and described below.
- $constant_name: This is required parameter. It specifies the name of the constant.
Return Value: This function returns TRUE if constant exists and FALSE otherwise.
Note: This function is available for PHP 4.0.0 and newer version.
Below examples illustrate the function:
Example 2: checking with if condition after defining the constant.
constant_key is defined
Example 3: checking with if condition without defining the constant.
constant_key is not defined
- How to find out where a function is defined using PHP ?
- Why error "$ is not defined" occurred in jQuery ?
- How to get the function name inside a function in PHP ?
- D3.js | d3.mean() function
- D3.js | d3.sum() function
- CSS | var() Function
- CSS | hsl() Function
- PHP | pi( ) Function
- D3.js | d3.set.has() Function
- p5.js | nfc() function
- p5.js | sin() function
- p5.js | nfp() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.