Home  >  Article  >  Backend Development  >  How to stop script execution in php

How to stop script execution in php

Guanhui
GuanhuiOriginal
2020-05-01 17:35:353266browse

How to stop script execution in php

How to stop script execution in php

To stop script execution in php, you can use "exit" and "die" Function, the essence of these two functions is the same. They stop the script from running. As long as the PHP script executes this function, it will stop executing the script. The difference between the two functions is that "exit" stops but does not release the memory, and "die" Stop and release memory.

Example

exit

<?php
echo "我是exit停止前!";
exit();//停止脚本
echo "我是exit停止后!";

Output result: I am exiting before stopping!

die

<?php
echo "我是die停止前!";
die();//停止脚本
echo "我是die停止后!";

Output result: I am die before stopping!

The above is the detailed content of How to stop script execution in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn