什么是ZF1的getPathInfo()方法的ZF2等价物?

时间:2014-04-18 18:21:42

标签: php zend-framework2

ZF1的Request :: getPathInfo()方法的ZF2等价物是什么?

2 个答案:

答案 0 :(得分:2)

您可以轻松地从 Uri 实例获取路径信息,该信息可通过请求实例访问。

在任何控制器动作中;

$path = $this->getRequest()->getUri()->getPath();

有关详细信息,请查看Zend\UriZend\Http\Request类。

答案 1 :(得分:0)

$request = new \Zend\Http\PhpEnvironment\Request();
var_dump($request->getUri());

object(Zend\Uri\Http)[5]
  protected 'validHostTypes' => int 19
  protected 'user' => null
  protected 'password' => null
  protected 'scheme' => string 'http' (length=4)
  protected 'userInfo' => null
  protected 'host' => string 'localhost' (length=9)
  protected 'port' => null
  protected 'path' => string '/iptcms/public_html/test.php' (length=28)
  protected 'query' => string '' (length=0)
  protected 'fragment' => null