0

我不知道如何从querystringPHP 中获取数据。

我想从access_token.

http://www.mygridview.com/sephora/index.php?mod=config#access_token=170791786296375|983b6aefceafdb1cf2d5a122-100001848355029|Hc8qGl6xgpXlmhOWQrLv910on_8&expires_in=0

我如何在 PHP 中做到这一点?

4

3 回答 3

1

The anchor part of a URL never gets sent to the server, so if you are trying to load this information from the current URL it won't be there.

As far as the server is concerned, the URL which is loaded by the browser is http://www.mygridview.com/sephora/index.php?mod=config

It's possible (maybe even likely) that some javascript is using the information in the anchor to restore the state of the page after it was altered using AJAX. In that case, it's the Javascript you'll need to look into to get that anchor information sent to the server

于 2011-01-21T11:58:32.480 回答
0

你得到 url,然后在 url 上应用解析函数。例如::

$url = 'http://username:password@hostname/path?arg=value#anchor';

print_r(parse_url($url));

Output::
Array
(
    [scheme] => http
    [host] => hostname
    [user] => username
    [pass] => password
    [path] => /path
    [query] => arg=value
    [fragment] => anchor
)

这个片段是你的要求。如果我是对的,那么试试这个 n 成功了。:) 谢谢

获取当前 URL::

function getInstance($uri = 'SERVER')
    {

            if ($uri == 'SERVER')
            {
                if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) {
                    $https = 's://';
                } else {
                    $https = '://';
                }

                if (!empty ($_SERVER['PHP_SELF']) && !empty ($_SERVER['REQUEST_URI'])) {
                    $theURI = 'http' . $https . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

                    if (strlen($_SERVER['QUERY_STRING']) && strpos($_SERVER['REQUEST_URI'], $_SERVER['QUERY_STRING']) === false) {
                        $theURI .= '?'.$_SERVER['QUERY_STRING'];
                    }
                }
                 else
                 {
                    $theURI = 'http' . $https . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
                    if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
                        $theURI .= '?' . $_SERVER['QUERY_STRING'];
                    }
                }

                $theURI = urldecode($theURI);
                $theURI = str_replace('"', '"',$theURI);
                $theURI = str_replace('<', '&lt;',$theURI);
                $theURI = str_replace('>', '&gt;',$theURI);
                $theURI = preg_replace('/eval\((.*)\)/', '', $theURI);
                $theURI = preg_replace('/[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']/', '""', $theURI);

        }
        echo (string)$theURI;
    }
于 2011-01-21T12:01:18.873 回答
0

结帐http://www.routesjs.com,您应该能够获取值并使用 ajax 将其发送出去。

于 2011-01-21T12:03:47.090 回答