0

Word文書を作成する小さなコードを書きましたが、次のエラーが発生しました

require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); グローバル $user;

$fp = fopen("test.doc", 'w+');
$str = "<B>This is the text for the word file created through php programming</B><br>test to create a doc file from php";
ob_start();
    include('index.php');
    $result = ob_get_clean();

fwrite($fp, $result);
    echo "executed";

header("Content-Disposition: attachment; filename=test.doc"); header("Content-Type: アプリケーション/強制ダウンロード"); header("Content-Length: " .filesize("test.doc")); header("接続: 閉じる");

fclose($fp);

?> 警告: ヘッダー情報を変更できません - ヘッダーは既に /var/www/www.example.com/htdocs/ の (/var/www/www.example.com/htdocs/test_createdoc.php:6 で開始された出力) によって通信されています19 行目の test_createdoc.php。 20 行目の .com/htdocs/test_createdoc.php。 www/www.example.com/htdocs/test_createdoc.php 行 21。 ) /var/www/www.example.com/htdocs/test_createdoc.php の 22 行目

PHPタグ間の空白も削除しました

4

1 に答える 1

1

echo "executed";ヘッダーの前に出力を送信するように見えます。HTTPでは出力の前にヘッダーが必要なため、PHPはヘッダーの送信を停止します。それを削除しても修正されない場合は、コメントアウトしてinclude('index.php');、出力がそこから来ているかどうかをテストしてみてください。

于 2010-02-04T21:07:23.567 に答える