Use http_build_query PHP () method for constructing a URL string (POST parameters may be converted into a GET request link spliced group)

http_build_query

(PHP 5, PHP 7)

http_build_query - after the request string generated URL-encode

 

. 1 <? PHP
 2  $ Data = Array (
 . 3      'foo' => 'bar',
 . 4      'baz' => 'Boom',
 . 5      'Cow' => 'Milk',
 . 6      'PHP' => 'Hypertext Processor'
 . 7      );
 . 8  
. 9  echo  http_build_query ( $ Data );
 10  / *  
. 11  * output: foo = bar & baz = Boom & Cow = Milk & PHP = Hypertext + Processor
 12 is  * / 
13 is ?>
 14 example 2. http_build_query () subject element under the use of digital
 15  
16 <?php
17 $data = array('foo', 'bar', 'baz', 'boom', 'cow' => 'milk', 'php' =>'hypertext processor');
18 
19 echo http_build_query($data);
20 /* 
21  * 输出:0=foo&1=bar&2=baz&3=boom&cow=milk&php=hypertext+processor
22 */
23 
24 echo http_build_query($data, 'myvar_');
25 /* 
26  * 输出:myvar_0=foo&myvar_1=bar&myvar_2=baz&myvar_3=boom&cow=milk&php=hypertext+processor
27 */
28 ?>

 

Guess you like

Origin www.cnblogs.com/jiayu123/p/11772673.html