language/control-structures/goto.xml
7204e2dbb9b484c8b67bb5ad4a93fa1369c5b317
...
...
@@ -10,8 +10,12 @@
10
10
<imageobject>
11
11
<imagedata fileref="en/language/figures/xkcd-goto.png" format="PNG"/>
12
12
</imageobject>
13
+
<caption>
14
+
<simpara>
15
+
Image courtesy of <link xlink:href="&url.xkcd;292">xkcd</link>
16
+
</simpara>
17
+
</caption>
13
18
</mediaobject>
14
-
Image courtesy of <link xlink:href="&url.xkcd;292">xkcd</link>
15
19
</para>
16
20
<para>
17
21
The <literal>goto</literal> operator can be used to jump to another
...
...
@@ -31,11 +35,13 @@
31
35
<programlisting role="php">
32
36
<![CDATA[
33
37
<?php
38
+

34
39
goto a;
35
40
echo 'Foo';
36
41

37
42
a:
38
43
echo 'Bar';
44
+

39
45
?>
40
46
]]>
41
47
</programlisting>
...
...
@@ -53,14 +59,18 @@ Bar
53
59
<programlisting role="php">
54
60
<![CDATA[
55
61
<?php
56
-
for($i=0,$j=50; $i<100; $i++) {
57
-
while($j--) {
58
-
if($j==17) goto end;
59
-
}
62
+

63
+
for ($i = 0, $j = 50; $i < 100; $i++) {
64
+
while ($j--) {
65
+
if ($j == 17) {
66
+
goto end;
67
+
}
68
+
}
60
69
}
61
70
echo "i = $i";
62
71
end:
63
72
echo 'j hit 17';
73
+

64
74
?>
65
75
]]>
66
76
</programlisting>
...
...
@@ -78,13 +88,15 @@ j hit 17
78
88
<programlisting role="php">
79
89
<![CDATA[
80
90
<?php
91
+

81
92
goto loop;
82
-
for($i=0,$j=50; $i<100; $i++) {
83
-
while($j--) {
84
-
loop:
85
-
}
93
+
for ($i = 0, $j = 50; $i < 100; $i++) {
94
+
while ($j--) {
95
+
loop:
96
+
}
86
97
}
87
98
echo "$i = $i";
99
+

88
100
?>
89
101
]]>
90
102
</programlisting>
91
103