字串的表示可以用" "或' ',不同處在於在" "中若出現已宣告的變數,會將其代號轉換成變數內容,而' '則不會。
(You can use also " " or ' ' to present a string, the difference is that if there are any variables in the string with " ", the output will be the content of the variable, although ' ' will only print the name of it.)
Ex:
$test1 = "hi";
$op1 = "$test1 ,I am handsome <br/>";
$op2 = '$test1 ,I am handsome';
echo $op1;
echo $op2;
輸出(output):
hi ,I am handsome
$test1 ,I am handsome
也可以用 . 來連接變數及字串。
(You may use . to combine variable and string, too.)
Ex:
$test1 = "hi";
$op1 = $test1 . " ,I am handsome <br/>";
$op2 = $test1 . ' ,I am somehand';
echo $op1;
echo $op2;
輸出(output):
hi ,I am handsome
hi ,I am somehand
沒有留言:
張貼留言