Hello @kartik,
you can use http_response_code() for get and set header status code.
here an example:
<?php
// Get the current response code and set a new one
var_dump(http_response_code(404));
// Get the new response code
var_dump(http_response_code());
?>
Hope it helps!!
Thank YoU!!