我使用的HTML代碼中的PHP象下面這樣:當我在PHP代碼中使用HTML代碼時它安全嗎?
echo '<span class="input-group-addon"><i class="glyphicon
glyphicon-pencil w3-large" name="topic_subject"> subject</i>
</span>
<br />
<textarea name="post_content" id="editor1"></textarea>
<br />
<div class="w3-col s1 m1 l1"><p></p></div>
<div class="w3-left">
<button class = "w3-button w3-xlarge tableButtons w3-middle"
id="save">save</button>
<a onclick="history.go(-1);" class="w3-button w3-xlarge
tableButtons w3-left">cancel</a>
</div>
</form>';
我使用單引號然後我用雙引號代替反斜槓逃脫。 這就是安全或不安全?
我投票作爲題外話,因爲它所需要的代碼審查(以及基於此從而過寬/意見)來關閉這個問題。它可能會被調整爲[code review stackexchange](http://codereview.stackexchange.com/help/on-topic)的主題。 – Quentin
安全嗎?用PHP的方式,是的,因爲你只是回聲一個字符串。 –
小修正,使用mysqli_real_escape_string(),不推薦使用mysql。你的代碼是100%安全的,不用擔心,當你只想在頁面上打印文本時沒有問題。 –