$url="http://127.0.0.1/test2.php?sitename=mysite.cn&a=1&b=2";
$a=parse_url($url);
p($a);
array(4) { ["scheme"]=> string(4) "http"
["host"]=> string(9) "127.0.0.1"
["path"]=> string(10) "/test2.php"
["query"]=> string(23) "sitename=mysite&a=1&b=2"
}
$data
=
array
(
'foo'
=>
'bar'
,
'baz'
=>
'boom'
,'site'
=>
'www.nowamagic.net'
)
$query_str
= http_build_query(
$data
)
;
将数组用&进行连接。
14 |
'baz' => 'boom' , |
15 |
'site' => 'www.nwamagic.net' , |
16 |
'name' => 'nowa magic' ); |
17 |
|
18 |