0

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/
Grzegorz Oledzki
  • 23,614
  • 16
  • 68
  • 106
Kalinin
  • 2,489
  • 8
  • 37
  • 49

3 Answers3

2

Take a look at the $_SERVER superglobal.

<?php
//example
echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URL'];
erenon
  • 18,838
  • 2
  • 61
  • 93
  • I explained the problem poorly. I need the address of the page which was the transition (last page). Not the current page. – Kalinin Mar 23 '10 at 09:33
1

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

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • I realized that this task without the string functions or regular expressions can not be solved. – Kalinin Mar 23 '10 at 14:20
0

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