大家好,本人初學php,關於html和php代碼嵌入有點不明白,
舉個例子:
There were some problems with the form you submitted.Please complete the fields highlighted below and click Send Details to resend the form.
Thanks for choosing to join The Widget Club. To register, please fillin your details below and click Send Details. Fields marked with an asterisk(*) are required.
為什麼這裡遇到“}”就把它單獨放置在中。為什麼不能寫成這樣?
There were some problems with the form you submitted.Please complete the fields highlighted below and click Send Details to resend the form. } else { Thanks for choosing to join The Widget Club. To register, please fillin your details below and click Send Details. Fields marked with an asterisk(*) are required.
}
非常感謝,解疑答惑!
回複內容:
大家好,本人初學php,關於html和php代碼嵌入有點不明白,
舉個例子:
There were some problems with the form you submitted.Please complete the fields highlighted below and click Send Details to resend the form.
Thanks for choosing to join The Widget Club. To register, please fillin your details below and click Send Details. Fields marked with an asterisk(*) are required.
為什麼這裡遇到“}”就把它單獨放置在中。為什麼不能寫成這樣?
There were some problems with the form you submitted.Please complete the fields highlighted below and click Send Details to resend the form. } else { Thanks for choosing to join The Widget Club. To register, please fillin your details below and click Send Details. Fields marked with an asterisk(*) are required.
}
非常感謝,解疑答惑!
因為
標籤屬於html而不是php語言,所以不能加到php起止符號內
表示他為php的 代碼塊結束符號“}”
因為
There were some problems with the form you submitted.Please complete the fields highlighted below and click Send Details to resend the form.
不是合法的PHP代碼.
在中的是php代碼,第二種寫法,很明顯標籤
中的內容不是php代碼。
如果想要用第二種寫法,可以這樣寫:
... '; } else { echo ' ...
'; } ?>
所有的非html代碼
都要嵌入在
內,而所有在
裡面的都會被解析為php代碼,按照你的想法,那一對
標籤裡的內容不屬於php代碼,所以應該是這樣分段嵌入的:
xxxxxx
7048
其實應該這樣理解
在php裡, ?> 表示開始輸出html,
可以這樣:
There were some problems with the ....
Thanks for choosing to join The Widget Club....
語言PHP的文法起始標籤就是 PHP的語言決定必須這麼寫!!!