Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

Keyword exit

Stop the script with an integer process status or print a string and stop with status zero.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

exit(0);

Stop the script with an integer process status or print a string and stop with status zero. Ordinary finally blocks are skipped on exit, but registered shutdown functions still run. In PHP 8.4 exit follows normal argument type handling and supports named arguments.

register_shutdown_function(fn()=>print("shutdown"));
try {echo "work "; exit(status:0);} finally {echo "finally ";}
work shutdown

Examples

<?php
register_shutdown_function(fn()=>print("shutdown"));
try {echo "work "; exit(status:0);} finally {echo "finally ";}

Result

work shutdown

Sources