Jump to content

$argv Not Sure How To Use Like I Need It


dzhax
 Share

Recommended Posts

I understand that this variable will hold all of the arguments passed to the script but I cant seem to get it to work correctly. I'm trying to pass the array into a single string so it will print out all of them. But before we get carried away, I want to make sure this is what i need.Im trying to determine what is typed in the address bar after the ?e.g:.../index.php?p=home&x=10&y=20i need the script to know that p=home&x=10&y=20 is already entered into the address bar and put that into a string on load of the page.e.g:$args = ...;thanks for any help

Link to comment
Share on other sites

Umm, $argv holds the value of command line arguments, if you run the PHP script from the command line. You use the $_GET superglobal to access querystring variables.

Link to comment
Share on other sites

So I read the page wrong. What would I use if the script didn't know what was being sent? Like I know I can use the $_get but thats only if the script knew exactly what to look for.What I am trying to do is just put everything after the ? into a string.

Edited by dzhax
Link to comment
Share on other sites

You can loop through get:

foreach ($_GET as $key => $value) {	//now $key holds the key and $value holds the value, one by one, for every key=value pair in the querystring}

Or you can use $_SERVER['QUERY_STRING'].

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...