In normal website development, we must deal with URLs. We can access specific addresses through URLs, and pass the parameters we need to test through URLs. Therefore, how to obtain the parameters in the URL becomes important. This blog post will explain how to get the parameters in the URL. This is just a function method that gets the parameters by passing the complete URL address string. The following is the code:
<?php /** * ======================================= * Created by Zhihua_W. * Author: Zhihua_W * Date: 2017/1/3 0009 * Time: 上午 11:03 * Project: PHP开发小技巧 * Power: 获取url中的各个参数 * ======================================= */ /** * 获取url中的各个参数 * 类似于 pay_code=alipay&bank_code=ICBC-DEBIT * @param type $str * @return type */ function parse_url_param($str) { $data = array(); $parameter = explode('&', end(explode('?', $str))); foreach ($parameter as $val) { $tmp = explode('=', $val); $data[$tmp[0]] = $tmp[1]; } return $data; } ?>
The above is the detailed content of PHP development skills (9) - How to obtain various parameters in the url. For more information, please follow other related articles on the PHP Chinese website!