-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathcontinue.xml
More file actions
171 lines (169 loc) · 3.89 KB
/
continue.xml
File metadata and controls
171 lines (169 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 16389a7b31069481d6c8c0705172bee5ef1ddf5f Maintainer: yannick Status: ready -->
<!-- Reviewed: no -->
<sect1 xml:id="control-structures.continue" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>continue</title>
<?phpdoc print-version-for="continue"?>
<simpara>
L'instruction <literal>continue</literal> est utilisée
dans une boucle afin d'éluder les instructions de
l'itération courante et de continuer l'exécution à la condition de
l'évaluation et donc, de commencer la prochaine itération.
</simpara>
<note>
<simpara>
En PHP, la structure
<link linkend="control-structures.switch"><literal>switch</literal></link>
est considérée comme une boucle par <literal>continue</literal>.
<literal>continue</literal> se comporte comme <literal>break</literal>
(lorsque aucun argument n'est passé) mais émettra un avertissement, car il
est probable que ceci soit une erreur. Si un <literal>switch</literal> se
trouve à l'intérieur d'une boucle, <literal>continue 2</literal> va continuer
sur la prochaine itération de la boucle externe.
</simpara>
</note>
<simpara>
<literal>continue</literal> accepte un argument numérique
optionnel qui indique combien de structures
emboîtées doivent être éludées. La valeur par défaut
est <literal>1</literal>, ce qui revient à aller directement
à la fin de la boucle courante.
</simpara>
<para>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
$arr = ['zero', 'one', 'two', 'three', 'four', 'five', 'six'];
foreach ($arr as $key => $value) {
if (0 === ($key % 2)) { // évite les membres pairs
continue;
}
echo $value . "\n";
}
?>
]]>
</programlisting>
&examples.outputs;
<screen>
<![CDATA[
one
three
five
]]>
</screen>
<programlisting role="php">
<![CDATA[
<?php
$i = 0;
while ($i++ < 5) {
echo "Extérieur\n";
while (1) {
echo "Milieu\n";
while (1) {
echo "Intérieur\n";
continue 3;
}
echo "Ceci n'est jamais affiché.\n";
}
echo "Ceci non plus.\n";
}
?>
]]>
</programlisting>
&examples.outputs;
<screen>
<![CDATA[
Extérieur
Milieu
Intérieur
Extérieur
Milieu
Intérieur
Extérieur
Milieu
Intérieur
Extérieur
Milieu
Intérieur
Extérieur
Milieu
Intérieur
]]>
</screen>
</informalexample>
</para>
<para>
Oublier le point-virgule après <literal>continue</literal> peut porter
à confusion. Voici un exemple de ce qu'il ne faut pas faire :
</para>
<para>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
for ($i = 0; $i < 5; ++$i) {
if ($i == 2)
continue
print "$i\n";
}
?>
]]>
</programlisting>
<para>
On peut s'attendre à ce que le résultat soit :
</para>
<screen>
<![CDATA[
0
1
3
4
]]>
</screen>
</informalexample>
</para>
<para>
<table>
<title>Historique pour <literal>continue</literal></title>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.3.0</entry>
<entry>
<literal>continue</literal> à l'intérieur d'un <literal>switch</literal>
qui tente d'agir comme une déclaration <literal>break</literal> pour
<literal>switch</literal> émettra <constant>E_WARNING</constant>.
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->