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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章