Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

What is the exact difference between esc_html and wp_filter_nohtml_kses. Everywhere I look says that both strip all the html, the only difference I can see is to do with exactly how they do this. Does esc_html encode the tags and does wp_filter_nohtml_kses strip them altogether?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

Contrary to what you have been looking at, esc_html does not strip all the HTML, it escapes it, meaning it encodes it into safe HTML entities that do not break HTML tags.

wp_filter_nohtml_kses strips all the HTML.

When in doubt always consult the source code. It is accessible online.

esc_attr is short and sweet, uses _wp_specialchars, defined in wp-includes/formatting.php

wp_filter_nohtml_kses is defined in wp-includes/kses.php, and "Strips all of the HTML in the content."

share|improve this answer
    
Thanks. I think it's hard enough to appreciate the differences between some of these validation functions. I mustn't have been paying enough attention to the distinction between 'escape' and 'strip'. –  byronyasgur Mar 9 '12 at 20:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.