In some scripts when i set http_response_code(401) or 500 when script is compiled it gaves a status code = 401 or 500 but in other scripts it gives me 200 OK even with an error in that script it will continue compiling it and returns 200 OK , I changed display_errors=On to Off and finally it gaves me the http_response_code(401) or 500 i writed in code but still executing the code , even if there is an error there it will execute all lines of the code after the error and efter the http_response_code(401)i think it must stop ? example :
<?php
header( 'Access-Control-Allow-Credentials: true');
header( "Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}" );
$x = 5;
http_response_code(500);
setcookie("X",$x,time()+300,null,null,null,true);
?>
that code must return a 500 status code and not set that cookie but in some codes i have it does and gives 200 OK (this 200 OK status code problem is solved by changing display_errors=Off in php.ini but stops me from seeing errors messages),is that a bug or that how it works ?