While running one PHP script. The script will call another one somewhere in the script. Those two scripts will need to run simultaneous so I can not use include or require here. The script will be called using the terminal like this:
exec( '/usr/bin/php ../process.php >> logs/' . date( 'Y_m_d' ) . '.log 2>&1 &' );
The big problem here is I want to process 6 different things, but they will all be using quite the same code. The only difference is the directory where they will be processed in.
Now the question: Is there a simple way to run the second script while passing one or more variables?
I tried something like ../process?var=something, but this clearly doesn’t work this way.
You can pass some variables as arguments to the script. All the arguments passed are in the variable
$argv.See php docs $argv
Then just loop through the
$argvand maybe check for some keywords you define.The
$argvvariable would then hold-fand/path/to/folder, so just check for-fin the loop and get the value by position of-f+1.