How to stop script execution in php

Guanhui
Release: 2023-02-28 21:24:01
Original
3345 people have browsed it

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停止后!";
Copy after login

Output result: I am exiting before stopping!

die

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

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template