Possible Duplicate:
Call another PHP script and return control to user before the other script completes
How to run a PHP script asynchronously from a another PHP script?
I have some problems on using exec() in PHP but I have no idea to solve it. I want to use exec() to execute another php script in same directory 'asynchronously'. I open a.php in browser to call b.php but it doesn't work. (the localhost is xampp on windows 7)
a.php:
<?php
exec('php \b.php', $output, $r);
print_r($output);
print_r($r);
?>
b.php:
#!/usr/bin/php
<?php
echo time();
?>
The output in browser
Array ( ) 1
I am super beginner on using something related PHP CLI... I have no idea about this... Can anyone give some simple examples? For example, what should be written in a.php and b.php.
Thanks a lot if you can give me some guides or advice!
EDIT:
I tried following code and it works but it does not run 'asynchronously'... How can I redirect the output?
Open callexec.php in browser.
callexec.php
<?php
exec('C:\xampp\php\php.exe testexec.php');
?>
testexec.php
<?php
echo "start: ",time(),"\n";
sleep(10);
echo "\n";
echo "end: ",time(),"\n";
?>
Thanks again.