Home » Functions » esc_url_raw

Function Name: esc_url_raw

The esc_url_raw function in WordPress is used to sanitize a URL or prepare it for output in a raw form. It’s designed to remove any characters that are not allowed in a URL and ensures that the output value is safe to use in an HTML attribute.

The function takes a URL as an argument and returns a string with the sanitized URL. This function is a more aggressive version of the esc_url function, which does a similar job but is less strict.

This function is useful when working with URLs that may include user input, such as URLs obtained from forms or comments. Escaping the URL with this function ensures that any potentially harmful input is removed, preventing security issues.

Here is an example usage code:

$unsafe_url = ‘