Home  >  Article  >  Backend Development  >  WordPres对前端页面调试时的两个PHP函数使用小技巧,_PHP教程

WordPres对前端页面调试时的两个PHP函数使用小技巧,_PHP教程

WBOY
WBOYOriginal
2016-07-12 09:02:36758browse

WordPres对前端页面调试时的两个PHP函数使用小技巧,

函数esc_js()(过滤 Html 内嵌 JS)
参数

$text

(字符串)(必须)要过滤的字符串。

默认值:None

返回值

(字符串)返回过滤后的字符串。

例子

<input type="text" value="<&#63;php echo esc_attr( $instance['input_text'] ); &#63;>" id="subbox" onfocus="if ( this.value == '<&#63;php echo esc_js( $instance['input_text'] ); &#63;>') { this.value = ''; }" onblur="if ( this.value == '' ) { this.value = '<&#63;php echo esc_js( $instance['input_text'] ); &#63;>'; }" name="email" />

更多

此函数位于:wp-includes/formatting.php

nocache_headers()(禁止浏览器缓存)
nocache_headers() 用来发送一个 header 头信息,告诉浏览器禁止缓存当前页面,一般在 Ajax 请求时使用,防止出现错误。

用法

nocache_headers();

属性

此函数没有属性。

返回值

此函数无返回值。

例子

function Bing_add_ajax(){
  nocache_headers();
  echo true;
  die;
}
add_action( 'template_redirect', 'Bing_add_ajax' );

其它

此函数位于:wp-includes/functions.php

您可能感兴趣的文章:

  • 几个优化WordPress中JavaScript加载体验的插件介绍
  • 快速掌握WordPress中加载JavaScript脚本的方法
  • 以JavaScript来实现WordPress中的二级导航菜单的方法
  • 用js代码和插件实现wordpress雪花飘落效果的四种方法
  • wordpress之js库集合研究介绍

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1084561.htmlTechArticleWordPres对前端页面调试时的两个PHP函数使用小技巧, 函数esc_js()(过滤 Html 内嵌 JS) 参数 $text (字符串)(必须)要过滤的字符串。 默认...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn