Get current URL excluding parameters in php
Firstly, to get the current url in php use the following:
<? $current_url = $_SERVER['REQUEST_URI']; echo $current_url; ?>
For URLs with trailing parameters the following will place the first part of the current URL (i.e. the part before ?) within the variable $current_url[0] and then print it out.
<? $current_url = explode("?", $_SERVER['REQUEST_URI']); echo $current_url[0] ; ?>
For example with the URL: