WordPres對(duì)前端頁(yè)面調(diào)試時(shí)的兩個(gè)PHP函數(shù)使用小技巧
函數(shù)esc_js()(過(guò)濾 Html 內(nèi)嵌 JS)
參數(shù)
$text
(字符串)(必須)要過(guò)濾的字符串。
默認(rèn)值:None
返回值
(字符串)返回過(guò)濾后的字符串。
例子
<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() 用來(lái)發(fā)送一個(gè) header 頭信息,告訴瀏覽器禁止緩存當(dāng)前頁(yè)面,一般在 Ajax 請(qǐng)求時(shí)使用,防止出現(xiàn)錯(cuò)誤。
用法
nocache_headers();
屬性
此函數(shù)沒(méi)有屬性。
返回值
此函數(shù)無(wú)返回值。
例子
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ū)別和比較
本篇文章是對(duì)php中的addslashes()與addclashes()函數(shù)的區(qū)別進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06php實(shí)現(xiàn)掃描二維碼根據(jù)瀏覽器類型訪問(wèn)不同下載地址
本程序?qū)崿F(xiàn)的功能就是掃描同一個(gè)二維碼根據(jù)瀏覽器類型訪問(wèn)不同下載地址,很實(shí)用的,建議大家學(xué)習(xí)下2014-10-10php生成隨機(jī)字符串可指定純數(shù)字、純字母或者混合的
這篇文章主要介紹了php生成隨機(jī)字符串的實(shí)現(xiàn)可指定純數(shù)字、純字母或者混合的2014-04-04PHP排序算法之基數(shù)排序(Radix Sort)實(shí)例詳解
這篇文章主要介紹了PHP排序算法之基數(shù)排序(Radix Sort),結(jié)合實(shí)例形式詳細(xì)分析了php基數(shù)排序算法的原理、實(shí)現(xiàn)方法與相關(guān)使用技巧,需要的朋友可以參考下2018-04-04