关于SO的第一个问题!
我在 apache 2.2.22 上运行 PHP 5.3.10。我只是这样做:
<html>
<body>
<?php
file_put_contents('php://stderr', print_r($_SERVER, TRUE));
?>
</body>
</html>
Apache 的 error.log 中的输出如下所示:
Array
(
[HTTP_HOST] => dns1
[PATH] => /usr/local/bin:/usr/bin:/bin
[SERVER_SIGNATURE] => <address>Apache/2.2.22 (Ubuntu) Server at dns1 Port 80</address>
[SERVER_SOFTWARE] => Apache/2.2.22 (Ubuntu)
[SERVER_NAME] => dns1
[SERVER_ADDR] => 192.168.2.6
[SERVER_PORT] => 80
[REMOTE_ADDR] => 98.210.76.128
[DOCUMENT_ROOT] => /var/www
[SERVER_ADMIN] => webmaster@localhost
[SCRIPT_FILENAME] => /var/www/rcv.php
[REMOTE_PORT] => 51164
[GATEWAY_INTERFACE] => CGI/1.1
R5 HTTP/1.0_PROTOCOL] => R5000
[REQUEST_METHOD] => GET
[QUERY_STRING] => UID=3333&DATA=R5000
[REQUEST_URI] => /rcv.php/?UID=3333&DATA=R5000
[SCRIPT_NAME] => /rcv.php
[PATH_INFO] => /
[PATH_TRANSLATED] => /var/www/index.html
[PHP_SELF] => /rcv.php/
[REQUEST_TIME] => 1369084575
)
传入的 http 请求的形式为:(来自 apache 的 access.log 的片段)
98.210.76.128 - - [20/5/2013:13:21:10 -0700] "GET /rcv.php/?UID=3333&DATA=R5000\rR5000\rR5000\rR5000\rR5000\rR5000\rR5000\rR5000\rR5000\ rR5000\rR5000\rR5000\rR5000\rR5000\rR5000\rR5000\rR5000\rR5000\rR5000\rR5000
(这是一系列传感器读数。在这种情况下,它们都是“R5000”。)
[QUERY_STRING]
and似乎在第[REQUEST_URI]
一个回车符 (\r) 处被截断,导致我丢失了其余的传感器读数。当我查看 $_GET 值时确认了这一点,DATA 字段中仅存在一个传感器读数。
我怎样才能避免这种情况或改变这种行为?