- sprintf: documentation ( source)
<?php
$tries = 0;
try {
a:
$tries++;
throw new \Exception(sprintf('Tried %d time(s)', $tries));
} catch(\Exception $exception) {
echo $exception->getMessage() . "\n";
if($tries > 4) {
goto b;
}
goto a;
}
b:
echo 'Finished\n';