本机测试php代码无错误,但是传服务器就500错误,而且还不报告具体原因,只返回500页面,哪里错了?

2014-01-15 22:35:17 +08:00
 ejin
反复测试了很多次,实在是想不到原因,很无奈,所以来求助下
<?php
$filename='adblock.txt';
@header("Content-Type content='text/html; charset=utf-8'");
if (file_exists($filename) == false) file_put_contents($filename,"");
if (isset($_POST['code'])) {
$code=str_replace('<','',$_POST['code']);
file_put_contents($filename,$code);
@ header("Location: ?");
exit();
};?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>adblock.txt编辑</title>
<style>
.gocode{width:100%;height:400px;background-color: #FCFCFC;border:1px #009ACE solid;font:12px tahoma;line-height:18px;}
.input-code{font-size:9pt;background:#ECF3FC;border-top:1px solid #fff;border-right:1px solid #aaa;border-bottom:1px solid #ccc;border-left:1px solid #fff;}
</style>
</head>
<body>
<center>
<form method='POST'>
<textarea class="gocode" name="code"><?php echo file_get_contents($filename);?>
</textarea>
<br />
<input type="submit" class="input-code" value="保存" />
<span class="code-tishi"></span>

</form>
</center>


</body>
</html>
5990 次点击
所在节点    PHP
4 条回复
Livid
2014-01-15 22:45:03 +08:00
txlty
2014-01-15 22:54:01 +08:00
@header("Content-Type content='text/html; charset=utf-8'"); 用错了!
把这条去掉就应该好了
ejin
2014-01-15 23:08:57 +08:00
@Livid 本人水平有限…… 玩不转…… 已感谢……虽然你不缺

@txlty 晕,果然去掉就可以了,真奇怪本地phpnow搭建的环境又能运行,好晕,感谢啦~l
siw
2014-01-15 23:13:34 +08:00
Content-Type: content

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/97172

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX