URL Parsing
Moderator: General Moderators
URL Parsing
Is there a way of using PHP to capture the current URL (including parameters) and so using this to send as a session variable?
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: URL Parsing
I'm not sure what you are refering to (i innitially thought $_GET) but here is a url which could be useful
http://webcheatsheet.com/php/get_current_page_url.php
http://webcheatsheet.com/php/get_current_page_url.php
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: URL Parsing
Threw this together in 2 minutes, so I can't promise it will work under every conceivable scenario.
Code: Select all
function getURL()
{
$string = (isset($_SERVER['HTTPS'])) ? 'https://' : 'http://';
$string .= $_SERVER['SERVER_NAME'];
$string .= $_SERVER['SCRIPT_NAME'];
$string .= ($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '';
return $string;
}