详见:http://php.net/manual/en/book.url.php
Example #1 parse_url() 例子
解析URL各类信息,存入数组:
以上例程会输出:
Array ( [scheme] => http [host] => hostname [user] => username [pass] => password [path] => /path [query] => arg=value [fragment] => anchor )
Example #2 parse_str() 例子
把参数查询字符串解析到变量中:
"; echo $age; ?>
在数组中存储变量:
Example #1 http_build_query() 例子
string http_build_query[1] ( array formdata [, string numeric_prefix])
(PHP 5)
根据数组产生一个urlencode之后的请求字符串,如果在基础数组中使用了数字下标同时给出了 numeric_prefix参数。
'bar', 'baz'=>'boom', 'cow'=>'milk', 'php'=>'hypertext processor'); echo http_build_query($data) . "\n"; echo http_build_query($data, '', '&'); ?>
example will output:
foo=bar&baz=boom&cow=milk&php=hypertext+processor foo=bar&baz=boom&cow=milk&php=hypertext+processor
Example #2 http_build_query() with numerically index elements.
'milk', 'php' =>'hypertext processor'); echo http_build_query($data) . "\n"; echo http_build_query($data, 'myvar_'); ?>
example will output:
0=foo&1=bar&2=baz&3=boom&cow=milk&php=hypertext+processor myvar_0=foo&myvar_1=bar&myvar_2=baz&myvar_3=boom&cow=milk&php=hypertext+processor
http://php.net/manual/en/function.http-build-query.php