I am using a php framework - Yii2
for developing an API
where I want to handle 4 types requests : GET
, POST
, PUT
and DELETE
. Here I can catch the parameters in GET
and POST
, but I can't access the parameters in PUT
and DELETE
methods.
I had found some codes after a wide search. But it didn't work fine for me. Sample code are:
Sample 1 :
$putdatafp = fopen("php://input", "r");
$putfp = fopen('php://input', 'r');
$putdata = '';
while($data = fread($putfp, 1024))
$putdata .= $data;
fclose($putfp);
var_dump($putdata);
Sample 2:
parse_str(file_get_contents("php://input"),$put_vars);
var_dump($put_vars);
But these two returns string datas. How can I parse the PUT
and DELETE
parameters into an array.
Any help would be greatly appreciated