How can I modify the parameter value of a url parameter? Is it necessary to split it and try again? How can I modify the parameter value of a url parameter? Is it necessary to split it and try again? Http: // 127.0.0.1/myo/newuser. php? Mod = search & amp; type = fastone. for example, how do I modify mod = new ?, If a request is sent, it cannot be changed. how can I modify the parameter value of a url parameter? Is it necessary to split it and try again?
How can I modify the parameter value of a url parameter? Is it necessary to split it and try again?
Http: // 127.0.0.1/myo/newuser. php? Mod = search & type = fastone
For example, now I want to modify mod = new
What should I do?
------ Solution --------------------
If a request is sent, it cannot be changed,
Only in this way.
$ Mod = $ _ GET ['mod'];
If ($ mod = 'search '){
$ Mod = 'new ';
}
If it is a string, you can
HTML code
Script var str = 'http: // 127.0.0.1/myo/newuser. php? Mod = search & type = fastone '; var re =/(mod =) (. + ?) (? = &)/I; str = str. replace (re, '$ 1new'); alert (str) script
------ Solution --------------------
To be simple, you can write as follows:
PHP code
$url='http://127.0.0.1/myo/newuser.php?mod=search&type=fastone';$url_arr=parse_url($url);parse_str($url_arr[query],$arr);$arr[mod]='new';echo 'http://'.$url_arr[host].$url_arr[path].'?'.http_build_query($arr);