Home > Backend Development > PHP Tutorial > http_build_query空格有关问题

http_build_query空格有关问题

WBOY
Release: 2016-06-13 12:27:10
Original
1619 people have browsed it

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 />?>
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template