The $output parameter of the exec command can be used to get the output of another PHP program:
callee.php
<?php echo "my return string\n"; echo "another return value\n"; exit(20);
caller.php
<?php exec("php callee.php", $output, $return_var); print_r(array($output, $return_var));
Running caller.php displays the following:
Array ( [0] => Array ( [0] => my return string [1] => another return value ) [1] => 20 )
Note that exit status must be a number in the range 0-254. See exit for more information on return status codes.
leepowers
source share