Sanitizing server name
-
Hi,
I’m using
$_SERVER['SERVER_NAME']
in my script to build a FROM email header.I want to sanitize the value before using it, but having difficulties finding the proper function for that. I want to get the URL without
http://
orhttps://
.Without sanitizing it will output the way I want:
$domain = $_SERVER['SERVER_NAME']; www.my-domain.com
This will output the full URL:
$domain = esc_url_raw($_SERVER['SERVER_NAME']); http://www.my-domain.com
This will strip the . characters from the URL:
$domain = sanitize_key($_SERVER['SERVER_NAME']); wwwmy-domaincom
I prefer using a native PHP/WP function instead of using extra functions to alter my output, such as
substr()
.Any thoughts?
Guido
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.