In php, after a header() jumps to another page, exit() must be added

高洛峰
Release: 2023-03-03 16:34:01
Original
1307 people have browsed it

In php, after a header() jumps to another page, exit() must be added

<?php
//如果答完题就跳转到结果页面
if($n==4){    
    header("Location:result/index.htm");
    exit();
}

$n = $n+1;
file_put_contents($_SERVER[&#39;DOCUMENT_ROOT&#39;].DIRECTORY_SEPARATOR."n.txt","00000000000000",LOCK_EX);
?>
Copy after login

If the header() jumps away without adding exit();, the following write statement will be executed (despite the jump to Another page, but the subsequent statements will still be executed).



For more related articles about adding exit() after a header() jumps to another page in PHP, please pay attention to the PHP Chinese website!

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!