language/control-structures/break.xml
7104ee97ced1768a3231588dfc0bc0d7eb1117ad
...
...
@@ -2,7 +2,7 @@
2
2
<!-- $Revision$ -->
3
3

4
4
<sect1 xml:id="control-structures.break" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
-
<title><literal>break</literal></title>
5
+
<title>break</title>
6
6
<?phpdoc print-version-for="break"?>
7
7
<simpara>
8
8
<literal>break</literal> ends execution of the current
...
...
@@ -13,7 +13,8 @@
13
13
<simpara>
14
14
<literal>break</literal> accepts an optional numeric argument
15
15
which tells it how many nested enclosing structures are to be
16
-
broken out of.
16
+
broken out of. The default value is <literal>1</literal>, only
17
+
the immediate enclosing structure is broken out of.
17
18
</simpara>
18
19
<para>
19
20
<informalexample>
...
...
@@ -21,7 +22,7 @@
21
22
<![CDATA[
22
23
<?php
23
24
$arr = array('one', 'two', 'three', 'four', 'stop', 'five');
24
-
while (list(, $val) = each($arr)) {
25
+
foreach ($arr as $val) {
25
26
if ($val == 'stop') {
26
27
break; /* You could also write 'break 1;' here. */
27
28
}
...
...
@@ -33,14 +34,14 @@ while (list(, $val) = each($arr)) {
33
34
$i = 0;
34
35
while (++$i) {
35
36
switch ($i) {
36
-
case 5:
37
-
echo "At 5<br />\n";
38
-
break 1; /* Exit only the switch. */
39
-
case 10:
40
-
echo "At 10; quitting<br />\n";
41
-
break 2; /* Exit the switch and the while. */
42
-
default:
43
-
break;
37
+
case 5:
38
+
echo "At 5<br />\n";
39
+
break 1; /* Exit only the switch. */
40
+
case 10:
41
+
echo "At 10; quitting<br />\n";
42
+
break 2; /* Exit the switch and the while. */
43
+
default:
44
+
break;
44
45
}
45
46
}
46
47
?>
...
...
@@ -48,35 +49,7 @@ while (++$i) {
48
49
</programlisting>
49
50
</informalexample>
50
51
</para>
51
-
<para>
52
-
<table>
53
-
<title>Changelog for <literal>break</literal></title>
54
-
<tgroup cols="2">
55
-
<thead>
56
-
<row>
57
-
<entry>&Version;</entry>
58
-
<entry>&Description;</entry>
59
-
</row>
60
-
</thead>
61
-
<tbody>
62
-
<row>
63
-
<entry>5.4.0</entry>
64
-
<entry>
65
-
<literal>break 0;</literal> is no longer valid. In previous versions it was interpreted
66
-
the same as <literal>break 1;</literal>.
67
-
</entry>
68
-
</row>
69
-
<row>
70
-
<entry>5.4.0</entry>
71
-
<entry>
72
-
Removed the ability to pass in variables (e.g., <literal>$num = 2; break $num;</literal>)
73
-
as the numerical argument.
74
-
</entry>
75
-
</row>
76
-
</tbody>
77
-
</tgroup>
78
-
</table>
79
-
</para>
52
+

80
53
</sect1>
81
54

82
55
<!-- Keep this comment at the end of the file
83
56