很多编程语言对于字符串的连接,只需要用加号+就OK了,例如:
JAVA:
String str1="Hello";
String str3=str1+"World";
System.out.println(str3);//输出结果为 Hello World;
但是PHP 是用点号 . 来连接字符串
PHP:
$str1="Hello";
$str3=$str1."World";// $str3==Hello Word
但是如果用加号+连接 ,PHP也不会报错,但是其中字符串变量为空
PHP:
$str1="Hello";
$str3=$str+"World";//$str3="Hello World"
本文对比了PHP和JAVA中字符串连接的方法。在JAVA中使用加号+即可完成字符串连接,而在PHP中则使用点号.。文章还提及了虽然PHP中使用加号不会报错,但结果有所不同。
379

被折叠的 条评论
为什么被折叠?



