我的 apache2 服务器上有一个文件 err.txt,我希望从网页上按原样查看该文件。
问题是 php 不会在该行的第一个非空格字符之前输出空格。就像它应该输出的那样:
这是错误:
curr_code.c:4:3: error: missing terminating " character
printf("Hello DIT\n');
^
但它输出:
curr_code.c:4:3: error: missing terminating " character
这是错误:
printf("Hello DIT\n');
^
我使用了file_get_contents()
、exec('cat err.txt',$out)
等等。
请建议 apt sols。
最佳答案
我认为这将是浏览器显示内容的方式,因为它会认为它是 HTML。要解决此问题,请尝试更改输出的内容类型;
header('Content-type: text/plain');
这需要在输出内容之前进行
关于php - 在服务器上输出一个文件,因为它是来自 php 的 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23930646/