|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
variables and command line
Hello:
I run acouple scripts via command line. Does anyone know how I can pass variables to my script via command line? |
|
#2
|
||||
|
||||
|
RE: variables and command line
Take a look at the getopt() function.
|
|
#3
|
|||
|
|||
|
RE: variables and command line
thanks honcho, I kind of understand that.
For example in my browser I would run the script like such; ./mysript.php?Date=2003-02-15 What would I write as command line using getopt? |
|
#4
|
|||
|
|||
|
RE: variables and command line
gigabyte,
Try using $argv[] argv[0] will be the name of the script $argv[1] will be the first parameter passed. Try it like this make a file test.php chmod 755 the file then try it ./test.php a_variable_to_pass It should print it for you. The first line sets the interpreter -q tells it quiet so it does not print the PHP version stuff. |
|
#5
|
|||
|
|||
|
RE: variables and command line
I have this same problem, and don't quite understand the above.
I have an older server that will pass the address lines' variables no worries. but my new one will not. Is this a new "feature" or is this an option in php.ini or another file? |
|
#6
|
|||
|
|||
|
RE: variables and command line
It's all right, I didn't know about the $_GET coommand. I've never had to use it before, my old server just passed them right through.
|
|
#7
|
|||
|
|||
|
RE: variables and command line
I know in some cases just plain $0 is the script name, and $1 $2, etc....are the variables afterwords.
What you are reffering to by having to use the $_GET variable is because of a thing called "register globals". If they are turned on in the config file, the variables should pass straight through. They are probably off in the new configuration. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Server Administration > variables and command line |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|