我正在使用Zend框架生成提要。
当我设置像下面这样的链接时,我得到一个错误
$feed = new Zend_Feed_Writer_Feed;
$url = "http://www.example.com/search?s=chris|gayle|pics&device=1"
$feed->setLink($url);
我搜索了Zend_Uri.php和Http.php,我没能找出问题。
异常'Zend_Feed_Exception',消息'无效参数:参数必须是一个非空字符串和有效的URI/IRI'
|
不允许。用%7C
代替。
更多信息请参见http://en.wikipedia.org/wiki/Percent-encoding#Types_of_URI_characters
使用urlencode
编码url。这将确保所有字符都被正确编码为标准URI。
您可能需要在URI中使用urlencode值
正确的URI应该是"http://www.example.com/search?s=chris%7Cgayle%7Cpics&device=1"
直接使用urlencode()或rawurlencode();对URI部分进行编码。
$url = "http://www.example.com/search?s=".urlencode("chris|gayle|pics")."&device=1"
根据哪些字符使URL无效?|不是有效的符号。
要在url中包含这些字符,必须对url进行编码。您可以使用urlencode方法来做到这一点。