CKTIS / PHP
Mot-clé exit
Arrête le script avec un statut entier ou affiche une chaîne et termine avec le statut zéro.
Version : PHP 8.4; repository runtime, production runtime not attested
Syntaxe
exit(0);Arrête le script avec un statut entier ou affiche une chaîne et termine avec le statut zéro. Les blocs finally ordinaires sont ignorés mais les fonctions de fin enregistrées s’exécutent. PHP 8.4 applique les règles habituelles de type et accepte un argument nommé.
register_shutdown_function(fn()=>print("shutdown"));
try {echo "work "; exit(status:0);} finally {echo "finally ";}
work shutdown
Exemples
<?php
register_shutdown_function(fn()=>print("shutdown"));
try {echo "work "; exit(status:0);} finally {echo "finally ";}
Résultat
work shutdown