我不知道这位朋友ShadowSniper(Metal Lovers) 解释的语言结构的概念对不对,我只知道 您说的我有几点不同意。 ====函数可能有返回值,而语言结构是没有返回值的===== echo()确实没有返回值,但是print也是语言结构,但是他又返回值,类型为boolean. php手册中: Description: int print ( string arg ) Outputs arg. Returns 1, always. print() is not actually a real function (it is a language construct) so you are not required to use parentheses with its argument list. =====语言结构比函数更 "直接 ".理论上来讲,使用语言结构比使用函数效率高. ===== 更直接是什么意思,难道像inline函数一样,还是像宏函数一样?效率高怎么得出,哪里有解释和说明
洗菜(菜);
放作料(菜);
煮熟(菜);
return 菜;
}这就是函数.
不过“你说的那些,除了echo,其他的都是函数.”似乎不妥!
<?--不过“你说的那些,除了echo,其他的都是函数.”似乎不妥!-->
我上面写的那些(不过“你说的那些,除了echo,其他的都是函数.”似乎不妥!)都是语言结构,不信可以从php手册中查一查。
<?--不过“你说的那些,除了echo,其他的都是函数.”似乎不妥!-->
我上面写的那些(echo(),print(),unset(),isset(),empty(),include(),require() 以及类似的语句)都是语言结构,不信可以从php手册中查一查。
您说的我有几点不同意。
====函数可能有返回值,而语言结构是没有返回值的=====
echo()确实没有返回值,但是print也是语言结构,但是他又返回值,类型为boolean.
php手册中:
Description:
int print ( string arg )
Outputs arg. Returns 1, always. print() is not actually a real function (it is a language construct) so you are not required to use parentheses with its argument list.
=====语言结构比函数更 "直接 ".理论上来讲,使用语言结构比使用函数效率高. =====
更直接是什么意思,难道像inline函数一样,还是像宏函数一样?效率高怎么得出,哪里有解释和说明
从没见过这些语句需要返回值,孤陋寡闻了.我看过不少文章在解释echo和print的区别时,都指出echo是语言结构,没有返回值.print是函数,有返回值,一直就这样认为了.关于print是语言结构,做为语言结构到底它是如何将值返回的.希望有人出来解释下.我也不太明白,应该属于php底层的东西了.
ShadowSniper(Metal Lovers) 说的基本就是了,
你还要多具体的?
具体的看PHP手册!