函数触发eventHough而没有终止符

时间:2015-12-16 10:39:35

标签: php function

我在php中有这个示例函数。

<?php

        function sample_function($atts)
        {
            echo $atts."<br/>";
        }

        sample_function("James");

        function another_function(){
            echo 'this is another function <br/>';
        }

        another_function()
?>

以上代码输出

James
this is another function 

我期待某种syntax error, unexpected end of file,但没有输出错误 我的php版本是5.6.15

我想知道这个php版本中是否存在这种错误? 或者我不知道这在php中是可行的。请提供一些信息。谢谢!

1 个答案:

答案 0 :(得分:1)

php块的结束标记在最后一行包含分号,所以你不需要在那里放分号这就是为什么你的函数会自动触发,在该函数行之后添加一些东西它将无法工作并告诉你有错误