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['DOCUMENT_ROOT'].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!