bbt*_*ang 4 php string concatenation string-concatenation
我刚发现了一些东西.
echo $var1 , " and " , $var2;
Run Code Online (Sandbox Code Playgroud)
是相同的:
echo $var1 . " and " . $var2;
Run Code Online (Sandbox Code Playgroud)
什么是PHP中的实际字符串连接运算符?我应该使用.还是,?
Mat*_*ley 14
该.运营商是连接运算符.你的第一个例子是有效的,因为echo'功能'(技术上它是一种语言结构,但不允许分裂头发)接受多个参数,并将打印每个参数.
因此,您的第一个示例是使用多个参数调用echo,并且它们都被打印,而第二个示例是所有字符串正在连接并且正在打印一个大字符串.