Created
March 9, 2019 08:23
-
-
Save zeshanshani/54ad41cd40eaf319c66bd1d8e2e839bb to your computer and use it in GitHub Desktop.
This function checks if the provided URL is of external site or not. Returns boolean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // do not copy this line. | |
/** | |
* Is External | |
* | |
* This function checks if the provided URL is external or not. | |
* | |
* Author URL: https://zeshanahmed.com/ | |
* | |
* @param string $url URL to be checked | |
* @author Zeshan Ahmed | |
* @return boolean | |
*/ | |
function is_external( $url ) { | |
$url_parts = parse_url( $url ); | |
return ! empty( $url_parts['host']) && strcasecmp( $url_parts['host'], $_SERVER['HTTP_HOST'] ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment