$protocol = getProtocol(); // http or https echo "The current protocol is: " . $protocol;
$url = getProtocol() . "://" . $_SERVER['HTTP_HOST'] . "/path/to/resource"; echo "The URL for the resource is: " . $url;This function seems to be a built-in function in PHP and does not require any package or library to be installed.