Jump to content

Variables Passed With Url


Recommended Posts

I’m writing page hits to a log file and I need to know the variables that are passed along with the actual php page or the results written to log file are useless.


$_SERVER['PHP_SELF'] gives me the name of the file executing the script (index.php or this_page.php), but not the accompanying variables.


Is there a way to give me the variables passed through the url as well?

(For example: www.example.com/index.php?var=test)

I would like to get the “?var=test” information.

Link to comment
Share on other sites

You either need to turn Register Globals to ON or use the $_GET[varname] to access the variables you are passing.

The problem with $_GET[varname] is that you have to know the varname you're looking for. Is there no way of actually getting the information that is in the url box on the browser?

Link to comment
Share on other sites

Since you are using php check out the documentation on parse_url

Thanks for another reply.

I think that may work, but how do I actually get the url from the page I'm working on. Meaning. The url will be dynamicaly generated by what the user may select from the page before. I need to get the url that is currently being displayed.

I hope you understand what I'm asking, or am I talking in circles.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...