Laravel从url获取查询

时间:2017-04-30 11:53:18

标签: php laravel url

如何从网址获取所有查询参数?

所以我们假设网址是:

http://website.com?page=1&?forum=test

我在控制器中需要这个部分:

http://website.com 页= 1&安培;?论坛=测试

查询参数可以与每个请求不同。因此,Input::get('page');Input::get('forum');无济于事 不知道可以期待什么。

已经看过docs,但我找不到它。

由于

1 个答案:

答案 0 :(得分:2)

您可以使用

获取所有参数
Downloading/unpacking pystan
  Downloading pystan-2.15.0.0.tar.gz (25.4MB): 25.4MB downloaded
  Running setup.py (path:/tmp/pip_build_ali/pystan/setup.py) egg_info for package pystan
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_ali/pystan/setup.py", line 239, in <module>
        setup_package()
      File "/tmp/pip_build_ali/pystan/setup.py", line 211, in setup_package
        dist = setup(**metadata)
      File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 321, in __init__
        _Distribution.__init__(self, attrs)
      File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
        self.finalize_options()
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 389, in finalize_options
        ep.require(installer=self.fetch_build_egg)
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2324, in require
        items = working_set.resolve(reqs, env, installer, extras=self.extras)
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 859, in resolve
        raise VersionConflict(dist, req).with_context(dependent_req)
    pkg_resources.VersionConflict: (six 1.5.2 (/usr/lib/python2.7/dist-packages), Requirement.parse('six>=1.6.0'))
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_ali/pystan/setup.py", line 239, in <module>

    setup_package()

  File "/tmp/pip_build_ali/pystan/setup.py", line 211, in setup_package

    dist = setup(**metadata)

  File "/usr/lib/python2.7/distutils/core.py", line 111, in setup

    _setup_distribution = dist = klass(attrs)

  File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 321, in __init__

    _Distribution.__init__(self, attrs)

  File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__

    self.finalize_options()

  File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 389, in finalize_options

    ep.require(installer=self.fetch_build_egg)

  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2324, in require

    items = working_set.resolve(reqs, env, installer, extras=self.extras)

  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 859, in resolve

    raise VersionConflict(dist, req).with_context(dependent_req)

pkg_resources.VersionConflict: (six 1.5.2 (/usr/lib/python2.7/dist-packages), Requirement.parse('six>=1.6.0'))

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_ali/pystan
Storing debug log for failure in /tmp/tmpXPB8XS

有关请求对象的更多信息,请访问Symfony's Request documentation页面。

这是一种访问请求数据的推荐方法,绝不依赖于$params = $request->query->all(); 等超级全局数组。