Reputation: 2519
Help me please get the value of the address bar of browser without the parameters passed. Without the use of regular expressions and string functions. You can do this? (I use php on apache).
enter
http://dev.mazda-parts.ru/catalogue/?spattern=1
exit
http://dev.mazda-parts.ru/catalogue/
Upvotes: 0
Views: 988
Reputation:
You say that you want the URL of the last page, which can be found in the $_SERVER['HTTP_REFERER']
variable.
Beware that this value is not reliable as it can be freely changed by the client.
If you want a more accurate way of finding the last page, you can use sessions. Here's an example:
session_start();
$last_page = $_SESSION['pageurl'];
$_SESSION['pageurl'] = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URL'];
// $last_page now contains a more reliable value for the last url
Upvotes: 0
Reputation: 19118
Take a look at the $_SERVER
superglobal.
<?php
//example
echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URL'];
Upvotes: 2
Reputation: 157880
parse_url() can help you, or some of the php string functions, like strtok()
Upvotes: 1