【发布时间】:2012-03-30 01:29:47
【问题描述】:
我在 localhost 中运行它,它可以工作。在服务器中,PHP 脚本返回空字符串。
包含脚本的 PHP 文件:
<body>
<table>
<tr>
<td>
<?php
function repstr($str) {
return str_replace("x", "y", $str);
}
echo stripslashes(urldecode(repstr($_REQUEST["par"])));
?>
</td>
</tr>
</table>
</body>
在 localhost 中调用的 URL:
https://localhost/myscript.php?par=x123
在服务器上:
https://domain.com/myscript.php?par=x123
两者都返回 HTML。但是 localhost 在 td 元素中有预期的内容,服务器 td 没有内容。
会是什么?
编辑:我目前无权访问服务器中的 PHP 文件。
【问题讨论】:
-
你看网页源码了吗?那里有任何警告或错误吗?
-
您没有将变量
code传递给 URL。你正在传递par。$_GET['par']有效吗? -
检查 PHP 错误日志。
-
尝试添加 var_dump($_REQUEST),看看你得到了什么。
-
注意,没有必要在
$_POST/$_GET/$_REQUEST/$_COOKIE上调用urldecode()。 PHP 会自动执行此操作。