$protocol checks if the current path contains http or https protocol
$_SERVER['HTTP_HOST'] as per manual definition is the contents of the Host: header from the current request.
$_SERVER['REQUEST_URI'] gets the full path of the page.
Example
I am running on localhost server and I have the current path as http://localhost/howto/edit.php?id=4.
Running the above code, will give me the ff values:
$protocol = http://
$_SERVER['HTTP_HOST'] = localhost
$_SERVER['REQUEST_URI'] = /howto/edit.php?id=4
$URL = http://localhost/howto/edit.php?id=4
That ends this tutorial. Happy Coding :)