- var_dump: documentation ( source)
- urlencode: documentation ( source)
- parse_url: documentation ( source)
<?php
var_dump(parse_url('https://example.com?foo&bar'));
$_GET = ['een', 'twee'];
$newUrl = "http://my-new-website.com/";
$currentPage = $_SERVER['PHP_SELF'];
//building the querystrging (if some GET variables where set):
$queryString = "?";
$firstRun = true;
foreach($_GET as $key => $value) {
if(!$firstRun) {
$queryString .= "&";
}
$queryString .= $key."=".urlencode($value);
}
var_dump($queryString);