問題:
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