运行我的脚本时,我收到几个这样的错误:
警告:不能更改头信息-头已经发出(输出开始/some/file.php:12)在/some/file.php上线23
错误消息中提到的行包含header()
和setcookie()
调用.
这可能是什么原因?以及如何解决它?
我的代码 -
if ($result)
{
$row = $result->fetch_object();
$filename = $row->src;
$q = "delete from photos WHERE id=$fileid";
$result = $mysqli->query($q) or die(mysqli_error($mysqli));
if ($result)
{
$filepath = "./images/";
if(fileDelete($filepath,$filename))
{
echo "success";
header("Location: index.php");
exit;
}
else echo "failed";
}
}
Run Code Online (Sandbox Code Playgroud)
输出 -
success Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\pics\deletepic.php:31) in C:\xampp\htdocs\pics\deletepic.php on line 32