如何检查file_get_contents是否有POST?

时间:2016-09-05 07:11:55

标签: php

您好我需要检查file_get_contents是否将数据发布到服务器..我的脚本看起来像这样

<?php
$foo = file_get_contents("http://www.example.com");

if ($_SERVER[REQUEST_METHOD] == POST)
{
// do action
}

echo $foo;
?>

我知道file_get_contents会停止我的脚本,感谢任何帮助

1 个答案:

答案 0 :(得分:0)

简单的file_get_contents调用永远不会将POST数据发送到服务器 - 只是一个简单的GET请求。所以你的$_POST var。

中没有任何东西

例外:

  • 其他服务器自行添加一些POST数据。
  • 您将上下文传递给file_get_contents,后者会将请求更改为POST请求