Home  >  Article  >  Backend Development  >  http_build_query空格有关问题

http_build_query空格有关问题

WBOY
WBOYOriginal
2016-06-13 12:27:101543browse

http_build_query空格问题

<?php <br />$data = array('foo'=>'bar', <br />              'baz'=>'boom', <br />              'cow'=>'milk', <br />              'php'=>'hypertext processor'); <br />echo http_build_query($data); <br />/* 默认输出: <br />       foo=bar&baz=boom&cow=milk&php=hypertext+processor <br />我想输出的格式<br />       foo=bar&baz=boom&cow=milk&php=hypertext%20processor <br />*/ <br />?>

本人新手,由于服务器规定是空格为%20才能识别,如果是+号则报错,而这个函数是否有替代品,或者是需要重构?谢谢大神。
------解决思路----------------------
用http_build_query得到foo=bar&baz=boom&cow=milk&php=hypertext+processor
再用str_replace函数去替换掉 + 号。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn