PHP文件编写问题.... [英] PHP file writing problem....
本文介绍了PHP文件编写问题....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想在一个文件中写一个字符串并让用户下载该文件。
但是当我写文件时,它还会写我的html文件中的其他文本。
我的源代码是这样的:
< html >
< head >
< 标题 > 文件检查< / title >
< / head >
< body &g t;
你好,你好吗...
< div >
<? php
$ string = 嘿,我只是在测试;
header(' Content-Disposition:attachment; filename =sample.html'< /跨度>);
header(' Content-Type:text / html');
header(' Content-Length:' .strlen($ string));
header(' Connection:close');
echo $ string ;
?>
< / div >
< / body >
< / html >
它的出局是:
你好,你好吗?
嘿,我只是测试
解决方案
string = 嘿,我只是在测试;
header(' Content-Disposition:attachment; filename =sample.html'< /跨度>);
header(' Content-Type:text / html');
header(' Content-Length:' .strlen(
串));
header(' Connection:close');
echo
string < /跨度>;
?>
< / div >
< / body >
< / html >
它的输出是:
你好,你好吗...
嘿我只是测试
I just want to write string in a file and let the user to download the file.
But when i write file its also write the other text from my html file.
My source code is this:
<html>
<head>
<title>File checking</title>
</head>
<body>
Hello how are you...
<div>
<?php
$string = "Hey i am just testing";
header('Content-Disposition: attachment; filename="sample.html"');
header('Content-Type: text/html');
header('Content-Length: ' . strlen($string));
header('Connection: close');
echo $string;
?>
</div>
</body>
</html>
And its out put is:
"Hello how are you...
Hey i am just testing"
解决方案
string = "Hey i am just testing"; header('Content-Disposition: attachment; filename="sample.html"'); header('Content-Type: text/html'); header('Content-Length: ' . strlen(
string)); header('Connection: close'); echo
string; ?> </div> </body> </html>
And its out put is:
"Hello how are you...
Hey i am just testing"
这篇关于PHP文件编写问题....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文