language/control-structures/goto.xml
890a03076b2708f65ff15fec9968ad6580131b36
...
...
@@ -2,7 +2,7 @@
2
2
<!-- $Revision$ -->
3
3

4
4
<sect1 xml:id="control-structures.goto" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
-
<title><literal>goto</literal></title>
5
+
<title>goto</title>
6
6
<?phpdoc print-version-for="goto"?>
7
7
<para>
8
8
<mediaobject>
...
...
@@ -10,12 +10,16 @@
10
10
<imageobject>
11
11
<imagedata fileref="en/language/figures/xkcd-goto.png" format="PNG"/>
12
12
</imageobject>
13
+
<caption>
14
+
<para>
15
+
Image courtesy of <link xlink:href="&url.xkcd;292">xkcd</link>
16
+
</para>
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
18
-
section in the program. The target point is specified by a label
22
+
section in the program. The target point is specified by a <emphasis>case-sensitive</emphasis> label
19
23
followed by a colon, and the instruction is given as
20
24
<literal>goto</literal> followed by the desired target label. This
21
25
is not a full unrestricted <literal>goto</literal>. The target
...
...
@@ -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>
...
...
@@ -97,11 +109,7 @@ script on line 2
97
109
</screen>
98
110
</example>
99
111
</para>
100
-
<note>
101
-
<para>
102
-
The <literal>goto</literal> operator is available as of PHP 5.3.
103
-
</para>
104
-
</note>
112
+

105
113
</sect1>
106
114

107
115
<!-- Keep this comment at the end of the file
108
116