Dibyendu Konar
Dibyendu Konar

Reputation: 165

receive json response in php

I have a url like this

localhost/handikap/insert/index.php?json={"id":123456}

and I want to get the json response out of it while I have written a code like this

$data = json_decode(file_get_contents('php://input'), true);
print_r($data);

but this is not returning anything Please help me out

Upvotes: 0

Views: 197

Answers (1)

Ramkumar P
Ramkumar P

Reputation: 206

If you are using GET method

$data = $_GET['json'];
$data = json_decode();
print_r($data);

If you are using POST method

$data = file_get_contents('php://input');
$data =  (array)json_decode($data,true);

Upvotes: 1

Related Questions