How to get address URL

How to get address URL

How to get the full address URL using PHP ..


/****
 * Get the url address
 */
 
 function getAddress()
 {
    // check for https 
    $protocol = (isset( $_SERVER['https']) == 'on' ? 'https' : 'http');
    //return address
    return $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
 }

 //usage 
 echo getAddress();

Will output the full URL 🙂

Leave a Reply

Be the First to Comment!

Notify of

wpDiscuz