<?php
goto target;
. . . . . .
target:
statement
where,
target = the target point specified by a label
statement = code to be executed
?>
<?php
for ($i1 = 0; $i1 <= 10; $i1++)
{
if ($i1 == 5)
{
goto point5;
}
elseif ($i1 == 6)
{
goto poincr6;
}
else
{
goto end;
}
}
point5:
echo 'Targeted to point5<br>';
poincr6:
echo 'Targeted to poincr6<br>';
end:
echo 'Targeted to end<br>';
?>
<?php
$i2 = mt_rand(1, 7);
if ($i2 == 5)
{
goto point5;
}
elseif ($i2 == 6)
{
goto poincr6;
}
else
{
goto end;
}
point5:
echo '( ' . $i2 . ' ) Targeted to point5<br>';
exit;
poincr6:
echo '( ' . $i2 . ' ) Targeted to poincr6<br>';
exit;
end:
echo '( ' . $i2 . ' ) Targeted to end<br>';
exit;
?>