You can get the current page URL in PHP using the $_SERVER['REQUEST_URI'] superglobal variable. 

Here's how you can do it:

<?php 
$currentURL = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo "Current page URL: $currentURL";
?>

This code will output the current page's URL, including the protocol (HTTP or HTTPS), the domain name, and the path to the current page.

Here's a breakdown of what's happening:

  • $_SERVER['HTTP_HOST'] contains the domain name of the server.
  • $_SERVER['REQUEST_URI'] contains the path and query string of the current URL.

By concatenating these two values with the http:// protocol, you get the complete URL of the current page.