我有一个简单的登录检查:
function send_error($message) {
header ( 'Content-Type: text/html; charset=utf-8' );
header ( 'HTTP/1.0 406 Not acceptable' );
echo $message;
exit ();
}
session_start ();
if (! isset ( $_SESSION ["login"] ) || $_SESSION ["login"] === "" || ! isset ( $_SESSION ["type"] )) {
send_error ( 'ERRORE: Devi prima aver eseguito il login per poter fare logout.' );
}
问题是如果用户没有登录,警告会出现在此部分之后的代码行。
为什么?
exit();
命令不应该停止执行代码吗?这是警告之一:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/people/ltw1313/cgi-bin/verifica_login.php:11) in /var/www/people/ltw1313/cgi-bin/verifica_post.php on line 13
答案 0 :(得分:0)
尝试在ob_flush();
header ( 'Content-Type: text/html; charset=utf-8' );