在PHP中使用GOTO命令? [英] GOTO command in PHP?

查看:133
本文介绍了在PHP中使用GOTO命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说有传言说PHP正在计划引入"goto"命令.它应该在做什么?

I've heard rumors that PHP is planning on introducing a "goto" command. What is it supposed to be doing?

我尝试了一下搜索,但是没有发现任何描述性很强的东西.我知道这不会是类似"GOTO 10"的命令...

I've tried searching a bit, but haven't found anything awfully descriptive. I understand that it won't be a "GOTO 10"-like command...

推荐答案

他们不是在添加真实的GOTO,而是将BREAK关键字扩展为使用静态标签.基本上,它将增强突破嵌套if语句的 switch 的能力.这是我发现的概念示例:

They are not adding a real GOTO, but extending the BREAK keyword to use static labels. Basically, it will be enhancing the ability to break out of switch nested if statements. Here's the concept example I found:

<?php
for ($i = 0; $i < 9; $i++) {
    if (true) {
        break blah;
    }
    echo "not shown";
    blah:
    echo "iteration $i\n";
}
?>

当然,一旦GOTO的谣言"出炉了,就没有什么可以阻止一些邪恶的人传播另外的 COMEFROM 笑话了.保持警惕.

Of course, once the GOTO "rumor" was out, there was nothing to stop some evil guys to propagate an additional COMEFROM joke. Be on your toes.

另请参阅:

http://www.php.net/~derick /meeting-notes.html#adding-goto

这篇关于在PHP中使用GOTO命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆