php

Set HTTP response code in php

<?php
    $status_code = 201;
    http_response_code($status_code);
?>

If you want to set response status code header in PHP, you can do that using http_response_code($status_code) function. This will return the status code from the HTTP request.

You can get information about status codes from below link

HTTP response codes

Was this helpful?