PHP: Fix For The Empty $_POST Array

One of the reasons I “love” PHP so much is that it sometimes poses problems the solution of which makes you scratch your head in wonder. Take for example the spurious “empty $_POST array” problem. It is easy to recognize for what happens is that parameters passed to a PHP script via a POST request won’t show up in the $_POST superglobal array.
To fix this, first make sure that you really pass the parameters. This can be easily checked:


  $mypostdata = file("php://input");
  print "<pre>"; 
  print "</pre>"

If your installation of PHP is ok, you should see the POST data you send to this script in both dumped outputs. If you see the data only in the second dump ($mypostdata), chances are your PHP installation is broken.

To fix it, all you need to do is reconfigure PHP with the additional flag


and compile the whole thing. Don’t worry, though! You don’t have to actually use “safe mode” afterwards. You just need to compile PHP with that setting. If you so wish you can disable safe mode afterwards by putting

safe_mode = Off

in your


. Makes me really scratch my head in wonder about the internal code dependencies ;)