GG資源網

WordPress「esc ..」函數是否有任何反轉功能?

問題描述:

I\'m using the standart \"esc_html\" in WordPress for insert data (textarea) to the db.

All works nice but how can I reverse the text?

For example:

I insert the text - You ready?! Let\'s go!

And in the db it\'s as I expected save it as - You ready?! Let's go!

Later, when I tried to display this text in my tooltip it\'s also display the text as You ready?! Let's go!

Please, I would like to know if there is any reverse for this function since I tried to use htmlspecialchars_decode() and realized it\'s not the same function.

Thanks!

圖片轉代碼服務由CSDN問答提供

感謝您的意見,我們儘快改進~
功能建議

我在Wordpress中使用標準「esc_html」將數據(textarea)插入資料庫。</ p >

一切正常但是如何反轉文本?</ p>

例如:</ p>

我插入文本 - < 強> 你準備好了嗎?! 我們走了!</ em> </ strong> </ p>

在資料庫中它正如我預期的那樣保存為 - 你準備好了嗎?! 讓我們走吧!</ code> </ p>

後來,當我試圖在我的工具提示中顯示這個文本時,它還顯示文本為你準備好了嗎?! 讓我們走吧!</ code> </ p>

請問,我想知道這個函數是否有任何反轉,因為我試圖使用htmlspecialchars_decode()並意識到它不是 相同的功能。</ p>

謝謝!</ p>
</ div>

網友觀點:

The answer is: generally speaking, you don\'t escape data when saving it to the database. You sanitize it. (And so you don\'t really need to worry about \\\"reverting\\\" the content from esc_* functions).

You sanitize the input data when you\'re about to insert it into the database to prevent SQL injection attacks. If you\'re using the insert() method from the $wpdb object or the wp_insert_post() function to create a new post/page, then the sanizitation is done for you automatically.

If you\'re writing a custom query (eg. $wpdb->query( \\\"INSERT INTO table VALUES(\'a string\', \'another string\', \'2018-09-21 10:35:52\')\\\" );) then you need to use the prepare() method to sanitize the query before running it (eg. $wpdb->query( $wpdb->prepare( \\\"INSERT INTO table VALUES(%s, %s, %s)\\\", array($string1, $string2, $date_string) ) );).

When you\'re about to display the data on screen use any of the different esc_* functions to make sure nothing malicious is being printed on screen (like <script>alert(\'Hello!\');</script>).

###

###

There is a PHP function for this!

Decoded String: \'You ready?! Let\'s go!\'

Documentation

由於網站搬家,部分鏈接失效,如無法下載,請聯繫站長!謝謝支持!
1. 帶 [親測] 說明源碼已經被站長親測過!
2. 下載後的源碼請在24小時內刪除,僅供學慣用途!
3. 分享目的僅供大家學習和交流,請不要用於商業用途!
4. 本站資源售價只是贊助,收取費用僅維持本站的日常運營所需!
5. 本站所有資源來源於站長上傳和網路,如有侵權請郵件聯繫站長!
6. 沒帶 [親測] 代表站長時間緊促,站長會保持每天更新 [親測] 源碼 !
7. 盜版ripro用戶購買ripro美化無擔保,若設置不成功/不生效我們不支持退款!
8. 本站提供的源碼、模板、插件等等其他資源,都不包含技術服務請大家諒解!
9. 如果你也有好源碼或者教程,可以到審核區發布,分享有金幣獎勵和額外收入!
10.如果您購買了某個產品,而我們還沒來得及更新,請聯繫站長或留言催更,謝謝理解 !
GG資源網 » WordPress「esc ..」函數是否有任何反轉功能?

發表回復

CAPTCHAis initialing...
© 2021-GG資源網 - www.ggplus.cn. All rights reserved