因为echo不是函数,所以在调用它时不使用括号。php echo不需要括号
例如:
echo "hello";
,而不是
echo ("hello");
如果它是一个函数,它会一直被迫被称为echo ("hello");
在ASP/VBScript中,我可以通过以下方式之一调用函数;
call dosomething("x","y","z")
dosomething "x","y","z" notice the missing parathesis
我在PHP中看到的这个无括号的语法中最接近的就是echo。我喜欢跳过括号的能力。
我的问题是,如果有一种方法可以在PHP中编写函数,那么不需要使用括号?
'echo'不是一个函数,而是一个“语言结构”(http://php.net/manual/en/function.echo.php),这就是为什么你可以使用没有括号。看看这个答案:http://stackoverflow.com/questions/1180184/what-is-the-difference-between-a-language-construct-and-a-built-in-function-in – Yaniro 2012-03-17 09:03:26