get url redirection - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of get url redirection.php
- <?php
- function get_parameters($url){
- $components = parse_url($url, PHP_URL_QUERY);
- @parse_str($components, $results);
- return (is_array($results))?$results:[];
- }
- // georges variation render
- // set get for exemple comment bellow line for production
- $_GET=array("name"=>"test","utm_content"=>"V3","utm_source"=>"ag2");
- $render_variation = 'https://www.geeksforgeeks.org/register?name=oda';
- // calculate new parameters for redirection
- if(is_array($_GET)){
- $new_parameters = array_diff_key($_GET,get_parameters($render_variation));
- } else {
- $new_parameters=[];
- }
- // final parameters
- $final_parameters = array_merge(get_parameters($render_variation),$new_parameters);
- // final url
- $redirect_url = strtok($render_variation,'?')."?".http_build_query($final_parameters);
- print_r($redirect_url);
- ?>
File Description
- get url redirection
- PHP Code
- 28 Apr-2022
- 799 Bytes
You can Share it:
Latest PHP Pastes