在PHP中关闭花括号后的分号 [英] Semicolon after closing curly bracket in PHP

查看:86
本文介绍了在PHP中关闭花括号后的分号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个脚本来制作文本的一部分并通过SMS发送.今天早些时候,我正在查看一些代码以将该字符串拆分为多个块,我看到了一些以前从未见过的东西.我说的是;"在摘要的en的}"之后.

I am writing a script to make chunks of a text and send it via SMS. Earlier today i was reviewing some code to split the string in chunks and i saw something I've never seen before. I'm talking about the ";" right after the "}" at the en of the snippet.

为什么是结肠?我知道它可以工作,但是我不知道它是否为解释器添加了一些语义或指令,有人知道这是做什么用的吗?

Why this colon? i know it works but i don't know if it adds some semantics or some instruction to the interpreter, anybody know what is this for?

while(1)
{
    $length = (strlen($output)+strlen($words[$i]));
    if($length>$new_max)
    {
        if(count($words) > 0)
        {
            $out_array[] = $output;
            $output = '';

        }
        else
        {
            break;    
        }
    }
    else
    {
        $output = $output." ".$words[$i];
        ++$i;
    };
};

很显然,分号和多个分号一起对结果没有影响,但是,您知道它对解释器是否有影响?它在解析任务时(内部)在执行某些任务吗?

Looks clear that the semicolons as well as multiple semicolons together has no effect over the result, but, do you know if it has some effect to the interpreter? is it doing some task (internally) when it parses it?

推荐答案

我认为这2个分号在这里不起作用.可能在if/while之后立即将其解释为空表达式.

I think that those 2 semicolons do nothing here. It is probably being interpreted as an empty expression immediately following the if/while.

这篇关于在PHP中关闭花括号后的分号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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