drupal 6 我们可以在 drupal 中编写一个 php 文件来更改标头
我写了一个小代码来创建一个word文档但是 我收到以下错误
require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); 全局$用户;
$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("内容处置:附件;文件名=test.doc"); header("内容类型:应用程序/强制下载"); header("内容长度:" .filesize("test.doc")); header("连接:关闭");
fclose($fp);
?> 警告:无法修改标头信息 - 标头已由 /var/www/www.example.com/htdocs/test_createdoc.php:6 中的 /var/www/www.example.com/htdocs/test_createdoc 中的 comnt 组成。 php 第 19 行。 警告:无法修改标头信息 - 标头已由 /var/www/www.example.com/htdocs/test_createdoc.php:6 中的 /var/www/www.example.com/htdocs/test_createdoc 中的 comnt 组成。 php 第 20 行。 警告:无法修改标头信息 - 标头已由 /var/www/www.example.com/htdocs/test_createdoc.php:6 中的 /var/www/www.example.com/htdocs/test_createdoc 中的 comnt 组成。 php第21行。 警告:无法修改标头信息 - 标头已由 /var/www/www.example.com/htdocs/test_createdoc.php:6 中的 /var/www/www.example.com/htdocs/test_createdoc 中的 comnt 组成。 php 第 22 行
我什至删除了 php 标签之间的空格
i have written a small code which creates a word document but
i got the following errors
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global $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: application/force-download");
header("Content-Length: " . filesize("test.doc"));
header("Connection: close");
fclose($fp);
?>
warning: Cannot modify header information - headers already comnt by (output started at /var/www/www.example.com/htdocs/test_createdoc.php:6) in /var/www/www.example.com/htdocs/test_createdoc.php on line 19.
warning: Cannot modify header information - headers already comnt by (output started at /var/www/www.example.com/htdocs/test_createdoc.php:6) in /var/www/www.example.com/htdocs/test_createdoc.php on line 20.
warning: Cannot modify header information - headers already comnt by (output started at /var/www/www.example.com/htdocs/test_createdoc.php:6) in /var/www/www.example.com/htdocs/test_createdoc.php on line 21.
warning: Cannot modify header information - headers already comnt by (output started at /var/www/www.example.com/htdocs/test_createdoc.php:6) in /var/www/www.example.com/htdocs/test_createdoc.php on line 22
i have even remove the white spaces between php tags
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来像
echo "executed";
在标头之前发送输出。然后 PHP 停止发送标头,因为 HTTP 要求标头出现在输出之前。如果删除它不能解决问题,请尝试注释include('index.php');
以测试输出是否来自那里。It looks like
echo "executed";
sends output before the headers. PHP then stops the headers from sending, because HTTP requires headers to come before output. If removing that doesn't fix it, try commenting outinclude('index.php');
to test if the output is coming from there.