如何在使用exit()/ die()之后继续php脚本 [英] How to continue a php script after using exit() / die()
本文介绍了如何在使用exit()/ die()之后继续php脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这种情况下,我想得到X1和Y1
的值,但是exit()是不要让我这么做
请提前感谢
特别感谢Mark Setchell:P(如果他看到的话) p>
$ im = imagecreatefromjpeg(omr.jpg); ($ y = 0; $ y <100; $ y ++)
$ b $($ x = 0; $ x <100; $ x ++){
$ b $ rgb = imagecolorat($ im,$ x,$ y);
$ r =($ rgb>> 16)& 0xFF的;
$ g =($ rgb>> 8)& 0xFF的;
$ b = $ rgb& 0xFF的; ($ r< 128&& $ g< 128& $ b< 128){
printf(%d,%d:%d,%d,%d \
,$ X,$ Y,$ R,$克,$ b);
出口; ($ x1 = 1170; $ x1 <1270; $ x1 ++){
y1 = 0; $ y1 <100; $ y1 ++){
$ rgb = imagecolorat($ im,$ x1,$ y1);
$ r1 =($ rgb>> 16)& 0xFF的;
$ g1 =($ rgb>> 8)& 0xFF的;
$ b1 = $ rgb& 0xFF的; ($ r1< 128&& $ g1< 128&& $ b1< 128){
printf(%d,%d:%d,%d,%d \
,$ X1,Y1 $,$ R 1,$ G1,$ B1);
出口;
lockquote
当前产出:
30,53:123,119,118
所需输出:
30,53:123,119,118
1217,55:115,114,112
解决方案您可以使用 break 2;
从两个嵌套for循环中断开,下一个循环用于 x1
和 y1
也会执行。
For example i have the following script.
in this case i want to get the value of X1 and Y1
but the the exit() is not letting me to do so
please help
thanks in advance
and special thanks to Mark Setchell :P (if he sees this)
$im = imagecreatefromjpeg("omr.jpg");
for($x=0;$x<100;$x++) {
for($y=0;$y<100;$y++)
{
$rgb = imagecolorat($im,$x,$y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
if($r<128 && $g<128 && $b<128){
printf("%d,%d: %d,%d,%d\n",$x,$y,$r,$g,$b);
exit;
}
}
}
for($x1=1170;$x1<1270;$x1++){
for($y1=0;$y1<100;$y1++){
$rgb = imagecolorat($im,$x1,$y1);
$r1 = ($rgb >> 16) & 0xFF;
$g1 = ($rgb >> 8) & 0xFF;
$b1 = $rgb & 0xFF;
if($r1<128 && $g1<128 && $b1<128){
printf("%d,%d: %d,%d,%d\n",$x1,$y1,$r1,$g1,$b1);
exit;
}
}
}
current output :
30,53: 123,119,118
Desired output :
30,53: 123,119,118
1217,55: 115,114,112
解决方案 You can use break 2;
to break from two nested for loops and your next for loop for x1
and y1
will also execute.
这篇关于如何在使用exit()/ die()之后继续php脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文