I have this lil snippet of PHP code:
function report ($data_to_send)
{
//$exec_string = 'nohup php ../serverside/error_writer.php ' . $data_to_send . ' >/dev/null 2>&1 &';
echo "Execution string: $exec_string </p>";
exec ("../serverside/error_writer.php $data_to_send > /dev/null 2>&1 &");
}
When this function is called, the PHP program should run error_writer.php and immediately continue execution. It should not stop and wait for output.
The program is, the parameters in $exec_string never get to error_writer.php.
Here is what I know:
- $exec_string and $data_to_send is not-empty
- Executing error_writer.php from the command line with some made up parameters behaves as designed (the parameters are correctly parsed and the program works as-intended)
- error_writer.php is being run, but with blank command line parameters
- Hard coding a fixed string (such as "Hi mom!") within the PHP does NOT work
- Looking up and googling similar problems gives no obvious indication what I am doing differently than anyone else
- I have also tried variations of the commented-out line with similar results. Stripping out all of the "run in the background and keep going" stuff doesn't seem to help.
Does anyone have any insight as to why command line parameters are just flat-out not making it to error_writer.php? I hope what I wrote is clear enough. Thank you.
Edit 1/20: So this ended up working for me.
$exec_string = 'php -d register_argc_argv=1 ../serverside/error_writer.php "' . $data_to_send . '" > /dev/null 2>&1 &';
-d overrides the php.ini settings, so the problem must have been in the configuration and not the actual code.