我收到一条错误消息:
警告:无法在/home/content/21/10941021/html/register.php中修改标题信息 - 已经发送的标题(/home/content/21/10941021/html/index.php:4中的输出开始)在第66行
我想我需要放一个ob_start()来使缓冲正常工作,但我无法理解它。问题包括我的代码:
<div class="lower-body">
<div class="left-lower">Create an account</div>
<div id="account-first">
<?php ob_start();
if (isset($_GET['success']) && empty($_GET['success'])){
echo 'You\'ve been registered successfully!';
echo 'Please check email and activate account!';
}else {
if(empty($_POST) === false && empty($errors) === true){
$register_data = array(
'firstname' => $_POST['firstname'],
'lastname' => $_POST['lastname'],
'username' => $_POST['username'],
'password' => $_POST['password'],
'email' => $_POST['email'],
'zipcode' => $_POST['zipcode']
);
register_user($register_data);
header('Location: register.php?sucess');
exit();
} else if(empty($errors) === false){
echo output_errors($errors);
}
}
ob_end_flush();?>
然后第4行是:
<?php
ob_start();
include 'includes/overall/head.php';
?>
任何想法? 非常感谢!
答案 0 :(得分:0)
header('Location: register.php?sucess');
应该在echo
编辑1:
在PHP代码的开头使用ob_start();
,在最后使用ob_end_flush();
,应该解决问题。
编辑2:使用此
<?php ob_start(); ?>
<div class="lower-body">
<div class="left-lower">Create an account</div>
<div id="account-first">
<?php
...
...
ob_end_flush();
?>