less than 1 minute read

function currentURL($server){ $isCLI = (php_sapi_name() == “cli”); if($isCLI){ return false; } $isHTTPS = isset($server[‘HTTPS’][0]); $HTTP_HOST = isset($server[‘HTTP_HOST’][0])?$server[‘HTTP_HOST’]:’’; $REQUEST_URI = isset($server[‘REQUEST_URI’][0])?$server[‘REQUEST_URI’]:’’; //쿼리 스트링이 이미 포함됨 $r = array(); $r[] = ($isHTTPS)?’https’:’http’; $r[] =’://’; $r[] = $HTTP_HOST; $r[] = $REQUEST_URI; return implode(‘’,$r); }

echo currentURL($_SERVER);


🔗original-link

Updated: