Necesito enviar "500 Internal Server Error" desde un script PHP bajo ciertas condiciones. Se supone que el script debe ser llamado por una aplicación de terceros. El script contiene un par de die("this happend")declaraciones para las que necesito enviar el 500 Internal Server Errorcódigo de respuesta en lugar del habitual 200 OK. El script de terceros reenviará la solicitud bajo ciertas condiciones que incluyen no recibir el 200 OKcódigo de respuesta.
Segunda parte de la pregunta: necesito configurar mi script de esta manera:
<?php
custom_header( "500 Internal Server Error" );
if ( that_happened ) {
die( "that happened" )
}
if ( something_else_happened ) {
die( "something else happened" )
}
update_database( );
// the script can also fail on the above line
// e.g. a mysql error occurred
remove_header( "500" );
?>
Necesito enviar el 200encabezado solo después de que se haya ejecutado la última línea.
Editar
Una pregunta secundaria: ¿puedo enviar 500 encabezados extraños como estos?
HTTP/1.1 500 No Record Found
HTTP/1.1 500 Script Generated Error (E_RECORD_NOT_FOUND)
HTTP/1.1 500 Conditions Failed on Line 23
¿El servidor web registrará dichos errores?