最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PHP GOTO函数的使用语法
时间:2022-06-25 00:47:36 编辑:袖梨 来源:一聚教程网
PHP的GOTO语法可以跳转到指定位置,如代码所示,goto display,在代码后面定义了一个display:,这样当执行goto display语句时,会跳到定义display的地方开始执行,这是PHP5.3增加的语法,支持PHP7.
public function index()
{
if (!I('get.search')) {
goto display;
}
//此处省略800字
$this->assign('account', self::$account);
$this->assign('pay_type', I('get.pay_type'));
$this->assign('list', $list);
display:
$this->display();
}
用法很简单:goto后面带上目标位置的标志,在目标位置上用目标名加冒号标记,如下:
代码如下:
goto a;
echo 'Foo';//此句被略过
a:
echo 'Bar';
//上面的例子输出结果为: Bar;
for($i=0,$j=50; $i<100; $i++) {
while($j--) {
if($j==17) goto end;
}
}
echo "i = $i";
end:
echo 'j hit 17';
//上面的例子输出结果为: j hit 17
?>
Note:
The goto 操作符仅在 PHP 5.3及以上版本有效.
相关文章
- 《腐蚀》资源介绍大全 04-29
- 《下一站江湖2》不水芸丹玄获得方法 04-29
- 《庄园领主》市场摊位机制介绍 04-29
- 《Open Roads》成就一览 04-29
- 《庄园领主》堡地大小介绍 04-29
- 《北海道游戏》基础攻略 简评+配置+下载 04-29