Page 1 of 1

Running php code locally passing parameters not working

Posted: Tue Oct 12, 2010 12:16 am
by Wootah
Hi all,

I open the cmd prompt and run a php script and it works. Ex: php script.php

I was hopeful I could use the querystring parameter Ex: php script.php?var1=A&var2=B

But I get: Could not open input file: ExtractOneDatabase.php?dbid=5

Is there a way to do this? Or do I need to pass parameters via an input file when run locally?

Thanks,

Mat

Re: Running php code locally passing parameters not working

Posted: Tue Oct 12, 2010 12:27 am
by Wootah
So far I have found:

var_dump($argv);

Re: Running php code locally passing parameters not working

Posted: Tue Oct 12, 2010 10:05 am
by AbraCadaver
Yes $argv will give you the parameters that were passed. If you want to use the query string as you have shown then you would do something like:
[text]php script.php var1=A&var2=B[/text]

Code: Select all

parse_str($argv[1]);