PHP | exit( ) Function Last Updated : 01 Aug, 2021 Comments Improve Suggest changes Like Article Like Report 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 to be displayed is passed as a parameter to the exit() function and it terminates the script and displays the message. The exit() function is an alias of the die() function. Syntax: exit(message) Parameters Used: The exit() function in PHP accepts one parameter. message : It is a mandatory parameter which specifies the message or status number to write before exiting the script. Return Value: It does not return any value. Errors And Exceptions exit() is a language construct and it can be called without parentheses if no status is passed. If the status passed as a parameter is an integer, that value will be used as the exit status and not be printed. Exit statuses should be in the range 0 to 254 and the exit status 255 should not be used since it is reserved by PHP. Below programs illustrate the exit() function: Program 1: php <?php $link = "https://www.geeksforgeeks.org"; // opening a link fopen($link, "r") //using exit() to display message and terminate script or exit("Unable to establish a connection to $link"); ?> Output: Unable to establish a connection to https://www.geeksforgeeks.org Program 2: php <?php //declaring variables $a=5; $b=5.0; if($a==$b) { //terminating script with a message using exit() exit('variables are equal'); } else { //terminating script with a message using exit() exit('variables are not equal'); } ?> Output: variables are equal Reference : http://php.net/manual/en/function.exit.php PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples. Comment More infoAdvertise with us Next Article PHP | exit( ) Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP Practice Tags : Misc Similar Reads PHP | fgets( ) Function The fgets() function in PHP is an inbuilt function which is used to return a line from an open file. It is used to return a line from a file pointer and it stops returning at a specified length, on end of file(EOF) or on a new line, whichever comes first. The file to be read and the number of bytes 2 min read PHP empty() Function The empty() function in PHP checks whether a variable is empty. It returns true if the variable has a value considered "empty," such as 0, null, false, an empty string, or an unset variable, and false otherwise. Syntaxbool empty ( $var )Parameter: This function accepts a single parameter as shown in 3 min read PHP | fgetc( ) Function The fgetc() function in PHP is an inbuilt function which is used to return a single character from an open file. It is used to get a character from a given file pointer. The file to be checked is used as a parameter to the fgetc() function and it returns a string containing a single character from t 2 min read PHP end() Function The end() function is an inbuilt function in PHP and is used to find the last element of the given array. The end() function changes the internal pointer of an array to point to the last element and returns the value of the last element.Syntax:end($array)Parameters:This function accepts a single par 2 min read PHP | fgetss( ) Function The fgetss() function in PHP is an inbuilt function which is used to return a line from an open file after removing HTML and PHP tags from the respective file. The fegtss() function stops returning at a specified length, on end of file(EOF) or on a new line, whichever comes first. The file to be re 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 PHP eval() Function PHP eval() function in PHP is an inbuilt function that evaluates a string as PHP code. Syntax: eval( $string ) Parameters: This function accepts a single parameter as shown in the above syntax and described below. $string: It must consist of a valid PHP code to be evaluated but should not contain op 2 min read PHP | ftell( ) Function The ftell() function in PHP is an inbuilt function which is used to return the current position in an open file. The file is sent as a parameter to the ftell() function and it returns the current file pointer position on success, or FALSE on failure.Syntax:  ftell( $file ) Parameters Used: The ftel 2 min read PHP | closedir( ) Function The closedir() function in PHP is an inbuilt function which is used to close a directory handle. The directory handle to be closed is sent as a parameter to the closedir() function and the closedir() closes the directory handle. The directory handle must be previously opened by the opendir() functio 2 min read PHP method_exists() Function The method_exists() function is an inbuilt function in PHP which used to check the class method exists or not. It returns "true" if the method exists otherwise returns "false". Syntax: bool method_exists( object|string $object_or_class, string $method );Parameters: This function accepts two paramete 1 min read Like