how to exit from function php code example
Example 1: php quit
exit(); // Normal exit
exit(1); // Exit with an error code
exit('Error!'); // Exit and print an error message
Example 2: exit and echo php
//exit — Output a message and terminate the current script
<?php
$filename = '/path/to/data-file';
$file = fopen($filename, 'r')
or exit("unable to open file ($filename)");
?>