views:

123

answers:

3

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/
+1  A: 

parse_url() can help you, or some of the php string functions, like strtok()

Col. Shrapnel
I realized that this task without the string functions or regular expressions can not be solved.
Kalinin
+2  A: 

Take a look at the $_SERVER superglobal.

<?php
//example
echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URL'];
erenon
What variable it could be?
Col. Shrapnel
I explained the problem poorly. I need the address of the page which was the transition (last page). Not the current page.
Kalinin
A: 

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
Charlie Somerville
using sessions for such a purpose is ridiculous
Col. Shrapnel
Yes. it is too cool for this small task.
Kalinin
@Col. Shrapnel: Notice I said 'if you want a more accurate...' I never said 'definitely do this'
Charlie Somerville