How to demonstrate the finally block in exception handling in PHP | PHP program
We will the finally block, finally block is a block that will always be executed whether an exception is generated or not.
<?php
try
{
$A = 10;
$B = 0;
if ($B == 0) throw new Exception("Divide by Zero exception");
$C = $A / $B;
printf("Value of C: %d<br>", $C);
}
catch(Exception $e)
{
printf("Exception: %s<br>", $e->getMessage());
}
finally
{
printf("Finally block executed");
}
?>


