开发者

Get address bar without parameters

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

ht开发者_Python百科tp://dev.mazda-parts.ru/catalogue/


Take a look at the $_SERVER superglobal.

<?php
//example
echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URL'];


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


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜