How can I modify the parameter value of a url parameter? Are you going to split it and try again?

Source: Internet
Author: User
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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.