Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. <?php
  2.  
  3. $cmd = "php /path/to/b.php";
  4.  
  5. $descriptorspec = [
  6. 0 => ["pipe", "r"], // stdin is a pipe that the child will read from
  7. 1 => ["pipe", "w"], // stdout is a pipe that the child will write to
  8. 2 => ["pipe", "w"] // stderr is a pipe that the child will write to
  9. ];
  10.  
  11. $process = proc_open($cmd, $descriptorspec, $pipes, realpath('./'), []);
  12.  
  13. // your program here
  14. echo 'this is a.php stuff';
  15. for($i = 0; $i < 5; $i++) { echo "."; sleep(1); }
  16.  
  17. // read the output of b.php at the end
  18. if (is_resource($process)) {
  19. while ($s = fgets($pipes[1])) {
  20. echo $s;
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement