PHP uiteindelik Sleutelwoord
Voorbeeld
Voer 'n paar kode uit, ongeag of 'n uitsondering gegooi is:
<?php
echo "Starting the process.";
try {
// Select
randomly between 0 and 1, throw an exception if 1 is selected.
$random = rand(0, 1);
if($random == 1) {
throw
new Exception("Exception");
}
} finally {
echo "Process
complete";
}
?>
Definisie en gebruik
Die finally
sleutelwoord word gebruik in try...finally
en try...catch...finally
strukture om 'n blok kode uit te voer, ongeag of 'n uitsondering plaasgevind het of nie.
Verwante bladsye
Die throw
sleutelwoord.
Die catch
sleutelwoord.
Die finally
sleutelwoord.
Lees meer oor uitsonderings in ons PHP-uitsonderingstutoriaal .
❮ PHP sleutelwoorde