Check if URL is external or internal in PHP. We are going to use parse_url PHP native function. Function parse_url parses a URL and returns an associative array containing any of the various components of the URL that are present.
Source code viewer
{ // internal link ... } else { // external link ... }Programming Language: PHP