Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function get_zero()
- {
- $res = rand(0, 9);
- if($res != 0) throw new \Exception('not a zero');
- return 'got a zero';
- }
- start:
- try {
- echo get_zero(), PHP_EOL;
- } catch(\Exception $e)
- {
- echo $e->getMessage(), PHP_EOL;
- goto start;
- }
- echo 'php will start over and over until exception not thrown', PHP_EOL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement