URI handler function
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-25 09:10:53
Original
1365 people have browsed it
This function was written by myself. My skills are not very good, so please let me know if there are any inappropriate parts
- function modifyUri($param = '', $value = '') {
- 2 //Get the current page URI
- 3 $uri = $_SERVER['REQUEST_URI'];
- 4 $uri = (parse_url($ uri));
- 5 //Split URI into arrays and delete duplicate items in the array
- 6 $uri = explode('&', $uri['query']);
- 7 $uri = array_unique($uri) ;
- 8 //Determine whether the function has a value passed in, and if so, perform replacement/insertion
- 9 if ('' != $param && '' != $value) {
- 10 $param .= '=';
- 11 $param_erge = '/'.$param.'.*/';
- 12 //Check whether the URI to be replaced already exists in the URI, and replace it if it exists
- 13 $uri = preg_replace($param_erge,$param.$value, $uri);
- 14 //If it does not exist, add it to the end
- 15 if('1' != in_array($param.$value, $uri)) array_push($uri, $param.$value);
- 16 }
- 17 //Convert the array to a string and return
- 18 $uri = implode('&', $uri);
- 19 $u = substr($_SERVER['REQUEST_URI'] , 0 , strpos($_SERVER[ 'REQUEST_URI'] , '?'));
- 20 $uri = "{$u}?".$uri;
- 21 return $uri;
- 22 }
Copy code
|
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2025-02-26 03:58:14
-
2025-02-26 03:38:10
-
2025-02-26 03:17:10
-
2025-02-26 02:49:09
-
2025-02-26 01:08:13
-
2025-02-26 00:46:10
-
2025-02-25 23:42:08
-
2025-02-25 22:50:13
-
2025-02-25 21:54:11
-
2025-02-25 20:45:11