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

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

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -