我想知道是否有可能在PHP中創建自定義中斷命令/函數。PHP中的create_function()自定義中斷命令/函數
例如,
<?php
$custombreak = create_function('$a', 'if ($a == 3) break 1;');
$i = 0;
do {
echo $i . '<br />';
$i++;
$custombreak($i); //<-- I'd like to break the loop with a custom function.
// if ($i==3) //<-- this is not what I'm looking for
// break;
} while ($i < 10);
?>
這是無效的PHP代碼,但我希望你明白我想說什麼。我想用函數逃避循環。
這不是問題的答案。 – Peter
只是試圖幫助他:S – user1609468