zend,得到一个值为http://的参数

时间:2011-06-23 10:59:28

标签: zend-framework

我试图从我的网址中获取一个参数...来自$this->_request->getParam('url')

所以,/ url / http://www.yahoo.com

但是param url的值是h,因为在值中有正斜杠。 我怎么能得到完整的网址...就像现在一样,它认为http://是另一个参数...

    public function getUrlToGo(){

$url=$this->_request->getParam('url');
if ($url='http://www.yahoo.com'){
return $this->_forward("findyahoo", "urlclass");

}
}

1 个答案:

答案 0 :(得分:0)

通常在地址栏中传递网址时,斜杠(以及大多数其他字符)会转换为网址安全字符。

<?php
$url = urlencode('http://www.yahoo.com');
echo $url; //http%3A%2F%2Fwww.yahoo.com

然后,您可以使用urldecode($url)来恢复原始网址。