A PHP function to return the current page URL.

<?php

 function getCurrentURL() {
  $CurrentURL  = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] :   'https://'.$_SERVER["SERVER_NAME"];
  $CurrentURL .= ( $_SERVER["SERVER_PORT"] !== 80 ) ? ":".$_SERVER["SERVER_PORT"] : "";
  $CurrentURL .= $_SERVER["REQUEST_URI"];
  return $url;
}

?>

Happy Coding!!!

Related Snippets

Last modified: May 8, 2019