Invalid body indentation level (expecting an indentation level of at least 4)

前端 未结 1 414
深忆病人
深忆病人 2021-01-21 10:14

I just upgraded to PHP 7.3 and I\'m getting this error:

Invalid body indentation level (expecting an indentation level of at least 4)

Here is t

1条回答
  •  说谎
    说谎 (楼主)
    2021-01-21 11:03

    This is caused by the new flexible Heredoc syntaxes in PHP 7.3.

    In previous versions of PHP, the closing marker was not allowed to have indentation:

        $string = <<

    As of PHP 7.3, the closing marker can be indented.

    In this example, EOF is indented by 4 spaces. The body of the string will also have 4 spaces stripped from the beginning of each line.

        $string = <<

    If the closing marker is indented further than any lines of the body, it will throw a Parse error:

        $string = <<

    The reason for the error message is two-fold:

    • The closing marker is indented further than 1 or more lines within the body

    But perhaps more likely, for those upgrading to PHP 7.3:

    • I've chosen a marker HTML which is also present within the string. Because of the flexible spacing now allowed, PHP was incorrectly detecting that the string had closed before I intended.

    0 讨论(0)
提交回复
热议问题