我試圖發送一個字符串,例如,「貓&狗」從PHP角度通過GET。我已經做了encodeURI(note)
和PHP發送'&'從一個字符串到PHP從角
$note = $_GET['note'];
$note = mysql_real_escape_string($note);
但是當它插入到數據庫中,只有當你想編碼把任何字符的「&」
我試圖發送一個字符串,例如,「貓&狗」從PHP角度通過GET。我已經做了encodeURI(note)
和PHP發送'&'從一個字符串到PHP從角
$note = $_GET['note'];
$note = mysql_real_escape_string($note);
但是當它插入到數據庫中,只有當你想編碼把任何字符的「&」
使用
encodeURIComponent(note)
使用encodeURIComponent
前一個URL參數
https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
代替
encodeURI(note)
使用encodeURI
當你想要一個工作URL
https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Global_Objects/encodeURI
這就是我一直在尋找的,謝謝 –
請張貼所有相關的代碼。 –
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent – epascarello
這是[off-topic(#1)](/ help/on-topic) t發佈了[mcve]。 – zzzzBov