rdoc76
asked on
Retrieve part of a Typed URL into a variable
Hi folks, I'm in need of help with the following situation:
I'm making a php page that retrieves the number typed after my domain from the user and uses it to verify it against a certain variable.
So what I would need would be the number typed in something like the following:
www.mydomain.com/123456
Is there a way to retrieve the typed number? I want the number and the page or folder doesn't exist since it is a variable...
Any help would be greatly appreciated.
Cheers!
I'm making a php page that retrieves the number typed after my domain from the user and uses it to verify it against a certain variable.
So what I would need would be the number typed in something like the following:
www.mydomain.com/123456
Is there a way to retrieve the typed number? I want the number and the page or folder doesn't exist since it is a variable...
Any help would be greatly appreciated.
Cheers!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think this would be more complicated than retrieving the value from the string.
Your address may be like www.mydomain.com/123/456/abc/def
how do you want - and what variables - to get them ?
Here's the little function
Then you can explode it with "/" and get all variables in an array.
Your address may be like www.mydomain.com/123/456/abc/def
how do you want - and what variables - to get them ?
Here's the little function
function getMyURL(){
$host = $_SERVER['HTTP_HOST'];
$self = $_SERVER['PHP_SELF'];
$par = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null;
$url = !empty($par) ? "http://$host$self?$par" : "http://$host$self";
return $url;
}
Then you can explode it with "/" and get all variables in an array.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
or :Open in new window