To get a current url you can use the code below:
1 |
$actual_link = ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] === 'on' ? "https" : "http" ) . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; |
To get the last parameter use the code example below:
1 2 3 4 5 6 |
$url_path = parse_url( $actual_link, PHP_URL_PATH ); $basename = pathinfo( $url_path, PATHINFO_BASENAME ); echo "<pre>"; print_r( $basename ); echo " |
With this you will be able to have the return of the last parameter of the url.