WordPres對前端頁面調(diào)試時的兩個PHP函數(shù)使用小技巧
函數(shù)esc_js()(過濾 Html 內(nèi)嵌 JS)
參數(shù)
$text
(字符串)(必須)要過濾的字符串。
默認值:None
返回值
(字符串)返回過濾后的字符串。
例子
<input type="text" value="<?php echo esc_attr( $instance['input_text'] ); ?>" id="subbox" onfocus="if ( this.value == '<?php echo esc_js( $instance['input_text'] ); ?>') { this.value = ''; }" onblur="if ( this.value == '' ) { this.value = '<?php echo esc_js( $instance['input_text'] ); ?>'; }" name="email" />
更多
此函數(shù)位于:wp-includes/formatting.php
nocache_headers()(禁止瀏覽器緩存)
nocache_headers() 用來發(fā)送一個 header 頭信息,告訴瀏覽器禁止緩存當前頁面,一般在 Ajax 請求時使用,防止出現(xiàn)錯誤。
用法
nocache_headers();
屬性
此函數(shù)沒有屬性。
返回值
此函數(shù)無返回值。
例子
function Bing_add_ajax(){ nocache_headers(); echo true; die; } add_action( 'template_redirect', 'Bing_add_ajax' );
其它
此函數(shù)位于:wp-includes/functions.php
相關(guān)文章
解析php addslashes()與addclashes()函數(shù)的區(qū)別和比較
本篇文章是對php中的addslashes()與addclashes()函數(shù)的區(qū)別進行了詳細的分析介紹,需要的朋友參考下2013-06-06php實現(xiàn)掃描二維碼根據(jù)瀏覽器類型訪問不同下載地址
本程序?qū)崿F(xiàn)的功能就是掃描同一個二維碼根據(jù)瀏覽器類型訪問不同下載地址,很實用的,建議大家學習下2014-10-10php生成隨機字符串可指定純數(shù)字、純字母或者混合的
這篇文章主要介紹了php生成隨機字符串的實現(xiàn)可指定純數(shù)字、純字母或者混合的2014-04-04PHP排序算法之基數(shù)排序(Radix Sort)實例詳解
這篇文章主要介紹了PHP排序算法之基數(shù)排序(Radix Sort),結(jié)合實例形式詳細分析了php基數(shù)排序算法的原理、實現(xiàn)方法與相關(guān)使用技巧,需要的朋友可以參考下2018-04-04