Get the App
SLTechnology News&Howtos  ›  Development  › 

How to keep the php code from executing down

Shulou Source: shulou.com Published: 2022-06-02 16:14:22 09月19日 Update

This article will explain in detail how to keep the php code from going down. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

In php, you can use the die () and exit () functions to prevent code from executing downward, with syntax of "die (message)" and "exit (status)"; the parameters "message" and "status" are used to specify the message or status number written before exiting the script, which cannot be omitted.

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

The way to keep the php code from executing downward:

When die () and exit () are called in the script, the entire script is terminated. They can all be used to prevent the script from continuing to execute so that some important actions do not occur.

1. Die ()

Phpdie is a function that outputs a message and exits the current script. Its syntax is "die (message)". The parameter "message" specifies the message or status number written before exiting the script, and the status number is not written to the output.

Output a message and exit the current script:

2. Exit ()

The function of phpexit is to output a message and exit the current script, the exit function is an alias for the die () function, its syntax is "exit (status)", and the parameter status specifies the message or status number written before exiting the script.

If status is a string, the function outputs the string before exiting.

If status is an integer, this value is used as the exit state. The value of the exit status is between 0 and 254. The exit status of 255 is reserved by PHP and will not be used. Status 0 is used to successfully terminate the program.

This is the end of this article on "how to keep php code from going down". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Tags: Scripts status messages functions output code parameters articles syntax characters strings more not bad practical important success between functions content aliases Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia macOS OPPO Reno Shulou Information Shulou Tech Info