For just capturing the stdout of another program (php or not), you can use backticks:
http://php.net/manual/en/language.operators.execution.php.
For example:
$boutput = `php b.php`;
Stdin yakalamak için, bu do:
$ainput = file_get_contents('php://stdin');
Finally, to pipe the contents of a string to an external program, use proc_open, as suggested by jeremy's answer.
Specifically, here's what your a.php should contain:
$ainput = file_get_contents('php://stdin');
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
);
$process = proc_open('php b.php', $descriptorspec, $pipes);
fwrite($pipes[0], $ainput);
fclose($pipes[0]);
echo stream_get_contents($pipes[1]); # echo output of "b.php < stdin-from-a.php"
fclose($pipes[1]);
proc_close($process);