PHP - 在字符串中连接或直接插入变量 - PHP - concatenate or directly insert variables in string

问题:

I am wondering, What is the proper way for inserting PHP variables into a string?我想知道,将 PHP 变量插入字符串的正确方法是什么?

This way:这边走:

echo "Welcome ".$name."!"

Or this way:或者这样:

echo "Welcome $name!"

Both of these methods work in my PHP v5.3.5 .这两种方法都适用于我的PHP v5.3.5 The latter is shorter and simpler but I'm not sure if the first is better formatting or accepted as more proper.后者更短更简单,但我不确定第一个是更好的格式还是被接受为更合适。


解决方案:

参考一: https://stackoom.com/question/NWMn
参考二: PHP - concatenate or directly insert variables in string
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章