Source Code:
(back to article)
<?php $success = true; // change this to false to return an error if ($success) { // set the status code to 200 to indicate success http_response_code(200); // return a JSON object with a message property echo json_encode(array("message" => "The request was successful")); } else { // set the status code to 400 to indicate an error http_response_code(400); // return a JSON object with a message property echo json_encode(array("message" => "There was an error processing the request")); }
Result:
Report an issue