angularjs - file_get_contents in php returns empty string

one text

Solution:

You're literally sending "123" by itself to the server. That isn't JSON, and it isn't an object, it's just a plain string.

So I suggest

  1. remove headers: { 'Content-type': 'application/json;charset=utf-8' } from the $http options,

  2. change $data = json_decode(file_get_contents("php://input")); to just $id_del = file_get_contents("php://input");

  3. remove $id_del = $data->send_id;

  4. change if(is_null($data)){ to if(is_null($id_del)){ and change var_dump($data);//empty string if(count(array($data)) > 0) { to var_dump($id_del);//empty string if(!empty($id_del) {

This will make PHP read just the plain string and use that as the ID, without attempting to decode it as JSON or extract values from within it.

Source