$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'
)
'foo'=>'bar',
'baz'
=>
'boom'
,
'site'
=>
'www.nowamagic.net'
'baz'=>'boom''site'=>'www.nowamagic.net'$query_str
$query_str= http_build_query(
$data
)
= http_build_query($data);
將數組用&進行鏈接。
15 |
'site' => 'www.nwamagic.net' , |
16 |
'name' => 'nowa magic' ); |