Assuming $_POST will always contain your POST data

Despite its name, the $_POST array won’t always contain your POST data and can be easily found empty. To understand this, let’s take a look at an example. Assume we make a server request with a jQuery.ajax() call as follows:

// js 
$.ajax({ url: '', method: 'post', data: JSON.stringify({a: 'a', b: 'b'}), contentType: 'application/json' });

Since $_POST is a superglobal, if we override it once (preferably early in our script), the modified value (i.e., including the POST payload) will then be referenceable throughout our code.

// php 
$_POST = json_decode(file_get_contents('php:input'), true);
array(2) { ["a"]=> string(1) "a" ["b"]=> string(1) "b" }