admin 发表于 2023-2-16 18:55:02

PHP中goto的使用方法

<div id="article_content" class="article_content clearfix">
      <link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/kdoc_html_views-1a98987dfd.css">
      <link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/ck_htmledit_views-6e43165c0a.css">
                <div id="content_views" class="htmledit_views">
                  <p>在PHP中使用goto方法去进行截至跳转</p>
<p>直接上线代码案例&#xff1a;</p>
<p>$number &#61; 1;</p>
<p>switch($munber){</p>
<p>        case 1:</p>
<p>                goto one:</p>
<p>                echo &#34;frist one&#34;;</p>
<p>        case 2:</p>
<p>                goto two:</p>
<p>                echo &#34;second two&#34;</p>
<p>        case3:</p>
<p>                goto three:</p>
<p>                echo &#34;third three&#34;;</p>
<p>}</p>
<pre>one:
echo &#34; 武林第一!&#34;;
//exit;
two:
echo &#34; 武林第二!&#34;;
//exit;
three:
echo &#34; 武林第三!&#34;;
//exit;
/*
最终结果是&#xff1a;武林第一! 武林第二! 武林第三!
注意后面的exit 注释了&#xff0c;为何不是最终输出 武林第一,大家可以琢磨下。
*/</pre>
                </div>
      </div>
      <div id="treeSkill"></div>
页: [1]
查看完整版本: PHP中goto的使用方法