當我做的$一個簡單的回聲HTTP_RAW_POST_DATA我得到的錯誤:未定義的變量:HTTP_RAW_POST_DATA
Undefined variable: HTTP_RAW_POST_DATA
,我讀了在php.ini我需要取消選中
always_populate_raw_post_data = On
但我仍然得到錯誤,我也重新啓動了Apache。即時通訊使用PHP 5.3.6
當我做的$一個簡單的回聲HTTP_RAW_POST_DATA我得到的錯誤:未定義的變量:HTTP_RAW_POST_DATA
Undefined variable: HTTP_RAW_POST_DATA
,我讀了在php.ini我需要取消選中
always_populate_raw_post_data = On
但我仍然得到錯誤,我也重新啓動了Apache。即時通訊使用PHP 5.3.6
如果您需要訪問原始POST體你真的應該傾向於使用php://input
流過$HTTP_RAW_POST_DATA
按照該relevant manual entry:
php://input is a read-only stream that allows you to read raw data from the request body. In the case of POST requests, it is preferable to use php://input instead of $HTTP_RAW_POST_DATA as it does not depend on special php.ini directives. Moreover, for those cases where $HTTP_RAW_POST_DATA is not populated by default, it is a potentially less memory intensive alternative to activating always_populate_raw_post_data. php://input is not available with enctype="multipart/form-data".
因此,訪問POST體使用php://input
:
$post = file_get_contents('php://input');
謝謝,當我讀到undefined時,我確實看到了這個,但是沒有想到使用它。但我錯了,謝謝! – 2012-03-04 07:46:39
如果你
Notice: Undefined variable: HTTP_RAW_POST_DATA
請打開你的服務器文件中添加找到
$server->service($HTTP_RAW_POST_DATA);
,並與下面的2行更換。
if (!isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA =file_get_contents('php://input');
$server->service($HTTP_RAW_POST_DATA);
我希望這會有所幫助。
您是否對任何Web服務使用任何HTTP_RAW_POST_DATA? – Milap 2012-03-04 07:38:57
在這個例子中,不,但我創始性地關注這個頁面http://phpmaster.com/web-services-with-php-and-soap-1/並得到了錯誤,所以我創建了一個頁面來調查錯誤。 – 2012-03-04 07:41:01