In PHP, why does [removed] not show a parse error?

前端 未结 2 1982
陌清茗
陌清茗 2021-01-30 00:48

I was running the following PHP code:


?>

There were no parse errors and the output was \"

2条回答
  •  醉话见心
    2021-01-30 01:12

    This must be because there are various ways of starting a block of PHP code:

    • (known as short_open_tag)

    • (the standard really)

    • (not recommended)

    • <% ... %> (deprecated and removed ASP-style tag after 5.3.0)

    Apparently, you can open a PHP block one way, and close it the other. Didn't know that.

    So in your code, you opened the block using but PHP recognizes as the closer. What happened was:

       <----- END PHP
    ?>          <----- JUST GARBAGE IN THE HTML
    

提交回复
热议问题