What’s the difference between esc_* functions?

esc_html and esc_attr are near-identical, the only difference is that output gets passed through differently named filters ( esc_html and attribute_escape respectively).

esc_url is more complex and specific, it deals with characters that can’t be in URLs and allowed protocols (list of which can be passed as second argument). It will also prepend input with http:// protocol if it’s not present (and link is not relative).

Leave a Comment