mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 08:28:54 +00:00

Closes GH-250. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@351935 c90b9560-bf6c-de11-be94-00142212c4b1
74 lines
1.8 KiB
XML
74 lines
1.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<sect1 xml:id="control-structures.break" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<title>break</title>
|
|
<?phpdoc print-version-for="break"?>
|
|
<simpara>
|
|
<literal>break</literal> ends execution of the current
|
|
<literal>for</literal>, <literal>foreach</literal>,
|
|
<literal>while</literal>, <literal>do-while</literal> or
|
|
<literal>switch</literal> structure.
|
|
</simpara>
|
|
<simpara>
|
|
<literal>break</literal> accepts an optional numeric argument
|
|
which tells it how many nested enclosing structures are to be
|
|
broken out of. The default value is <literal>1</literal>, only
|
|
the immediate enclosing structure is broken out of.
|
|
</simpara>
|
|
<para>
|
|
<informalexample>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$arr = array('one', 'two', 'three', 'four', 'stop', 'five');
|
|
foreach ($arr as $val) {
|
|
if ($val == 'stop') {
|
|
break; /* You could also write 'break 1;' here. */
|
|
}
|
|
echo "$val<br />\n";
|
|
}
|
|
|
|
/* Using the optional argument. */
|
|
|
|
$i = 0;
|
|
while (++$i) {
|
|
switch ($i) {
|
|
case 5:
|
|
echo "At 5<br />\n";
|
|
break 1; /* Exit only the switch. */
|
|
case 10:
|
|
echo "At 10; quitting<br />\n";
|
|
break 2; /* Exit the switch and the while. */
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
</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
|
|
-->
|