PHP以分号结尾

时间:2015-08-14 21:05:38

标签: php if-statement

我在一些旧的PHP代码中遇到过这个问题,但仍在使用并且有效。我无法找到任何Google搜索结果,也从未见过它。 在其他人之后用分号进行了什么?

if($placeholder_name=="###google_adwords_conversion###")
{
    if(!$currentSiteIsLive)
    {
        return "";
    }
    else;
}
else if($placeholder_name=="###google_visitor###")
{
    if(!$currentSiteIsLive)
    {
        return "";
    }
    else;
}
else;

3 个答案:

答案 0 :(得分:1)

大括号被视为终止字符。它们用于包含复合语句块。所以最后不需要使用分号。

ForslagOpslagLikes -> fk_brugerid to ForslagOpslag -> fk_brugerid

ForslagOpslagLikes -> getid to ForslagOpslag -> id

如果你只有一个声明,最后会加一个分号。

if {
// code
}

我知道这很难看。

答案 1 :(得分:0)

它没有做任何事情。它只是告诉php其他 - >没做什么。我相信编写该代码的人认为if语句应该总是有一个else语句。

答案 2 :(得分:0)

its basically saying if not true then do not do anything you can acheive the same with curly brackets. like this:

else { }

相关问题