mirror of
https://github.com/php/doc-es.git
synced 2026-04-28 17:43:11 +02:00
77 lines
2.0 KiB
XML
77 lines
2.0 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 7104ee97ced1768a3231588dfc0bc0d7eb1117ad Maintainer: PhilDaiguille Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
|
|
<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>
|
|
La instrucción <literal>break</literal> permite salir de una estructura
|
|
<literal>for</literal>, <literal>foreach</literal>,
|
|
<literal>while</literal>, <literal>do-while</literal>
|
|
o <literal>switch</literal>.
|
|
</simpara>
|
|
<simpara>
|
|
<literal>break</literal> acepta un argumento numérico opcional
|
|
que indicará cuántas estructuras anidadas deben ser
|
|
interrumpidas. El valor por omisión es <literal>1</literal>, solo la
|
|
estructura anidada inmediata es interrumpida.
|
|
</simpara>
|
|
<para>
|
|
<informalexample>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$arr = array('un', 'dos', 'tres', 'cuatro', 'stop', 'cinco');
|
|
foreach ($arr as $val) {
|
|
if ($val == 'stop') {
|
|
break; /* También podría utilizarse 'break 1;' aquí. */
|
|
}
|
|
echo "$val<br />\n";
|
|
}
|
|
|
|
/* Uso del argumento opcional. */
|
|
|
|
$i = 0;
|
|
while (++$i) {
|
|
switch ($i) {
|
|
case 5:
|
|
echo "At 5<br />\n";
|
|
break 1; /* Termina únicamente el switch. */
|
|
case 10:
|
|
echo "At 10; quitting<br />\n";
|
|
break 2; /* Termina el switch y el ciclo 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
|
|
-->
|