PHP | defined() function Last Updated : 23 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. Syntax: bool defined($constant_name); 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 1: php <?php define("constant_key", "value for the constant key"); echo defined("constant_key"); ?> Output: 1 Example 2: checking with if condition after defining the constant. php <?php define("constant_key", "value for the constant key"); if(defined("constant_key")){ echo "constant_key is defined"; }else{ echo "constant_key is not defined"; } ?> Output: constant_key is defined Example 3: checking with if condition without defining the constant. php <?php //define("constant_key", "value for the constant key"); if(defined("constant_key")){ echo "constant_key is defined"; }else{ echo "constant_key is not defined"; } ?> Output: constant_key is not defined Comment More infoAdvertise with us Next Article PHP | exit( ) Function G gekcho Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP define() Function The define() function is basically used by programmers to create constant. Constants in PHP are very similar to variables and the only difference between both are the values of constants can not be changed once it is set in a program. define() returns a Boolean value. It will return TRUE on success 2 min read PHP | get_defined_vars() Function The get_defined_vars() function is an inbuilt function in PHP which is used to returns an array of all defined variables. This function returns a multidimensional array which contains all the list of variables, environment etc. Syntax: array get_defined_vars( void ) Parameters: This function does no 1 min read PHP | exit( ) Function The exit() function in PHP is an inbuilt function which is used to output a message and terminate the current script. The exit() function only terminates the execution of the script. The shutdown functions and object destructors will always be executed even if exit() function is called. The message 2 min read PHP fileinode() Function The fileinode() function is an inbuilt function in PHP that returns the inode of the file. Syntax: fileinode(string $filename): int|falseParameter: This function has only one parameter: filename: This parameter specifies the path for the particular file.Return Value: This function returns the inode 1 min read PHP is_file( ) Function The is_file() function in PHP is an inbuilt function which is used to check whether the specified file is a regular file or not. The name of the file is sent as a parameter to the is_file() function and it returns True if the file is a regular file else it returns False. Syntax: bool is_file($file) 2 min read PHP file_exists( ) Function The file_exists() function in PHP checks whether a file or directory exists on the server. It returns a boolean value:true: If the file or directory exists.false: If the file or directory does not exist or the path is incorrect.Syntax:file_exists($path)In this syntax: The file_exists() function in P 2 min read Like