Home  >  Article  >  Backend Development  >  In php, after a header() jumps to another page, exit() must be added

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

高洛峰
高洛峰Original
2016-12-20 09:50:511252browse

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);
?>

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!

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