重複の可能性:
PHP によって既に送信されたヘッダー
PHP初心者でダウンロードボタンを作りたいのですが、よくわからないエラーが出てしまいました。これは私のエラーです:
「警告: ヘッダー情報を変更できません - D:\Program Files\xampp\htdocs\FormsGenerator\download.php の (D:\Program Files\xampp\htdocs\FormsGenerator\index.php:125 で出力が開始された) によって既に送信されたヘッダー11号線で」
125 行で、作成した関数を呼び出すために php のタグを開きました。これはボタン機能の私のタラです:
<?php
class fileDownload{
function fileDownload(){
$core_path = dirname(__FILE__);
$file_path = "{$core_path}/file/form.html";
$file_info = array(
'name' => basename($file_path),
'size' => filesize($file_path)
);
header('Content-Type: application/html');
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="'.$file_info['name'].'"');
header('Content-Lenght: '.$file_info['size']);
$file = fopen($file_path, 'rb');
while(!feof($file)){
echo fread($file, 256);
}
fclose($file);
return;
}
}
?>
そして、クラスを呼び出す作成されたオブジェクトは次のとおりです。
if(isset($_GET['download'])){
include 'download.php';
$download = new fileDownload();
}
誰かが私を助けることができますか?