$currentUrl = getUrl(); echo $currentUrl; // outputs "http://example.com/mypage.php?foo=bar"
$currentUrl = getUrl(); $qsParams = parse_url($currentUrl, PHP_URL_QUERY); parse_str($qsParams, $params); echo $params['foo']; // outputs "bar"In this example, the getUrl() function is used to retrieve the URL of the current page. The parse_url() function is then used to retrieve only the query string parameters from the URL, which are stored as a string. The parse_str() function is then used to parse the string into an associative array, which can be used to access the values of the query string parameters. In this case, the value of the 'foo' parameter is echoed to the screen. Package/Library: This example uses the built-in PHP functions 'parse_url()' and 'parse_str()'.