Suppose you have to retrieve the URL of the application in PHP i.e http://example.com
Using this piece of code
//output : example.com
$DOMAIN = $_SERVER['SERVER_NAME'];
// output: http://
$protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://';
// output : http://example.com
$main_url = $protocol.$DOMAIN;
When...
