ftp - how to send string response in php -


i trying send string response of particular request ftp interface. using below code..

if($s == 'successfull') {     $rid = 's'.$request_id;             } if($s == 'unsuccessfull') {     $rid = 'e'.$request_id;             } echo "<b style='font-size: 16px;color:#59ab8f;'>your request id:".$rid.".......<b>\n"; printf("<br>"); header($rid); 

why not set response code json response?

if($s == 'successfull'){   http_response_code(201);    $data = [ 'id' => $request_id ];  } else {   http_response_code(400);     }  if (isset($data)) {   header('content-type: application/json');   echo json_encode($data); } 

that normal way of handling api post response. 201 signifies resource created, 400 signifies bad request (you can change if different response code matches better). client can read in json data , id.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

android - MPAndroidChart - How to add Annotations or images to the chart -