Check the second example in the documentation on popen, it shows exactly how to do that:
&1', 'r');
echo "'$handle'; " . gettype($handle) . "\n";
$read = fread($handle, 2096);
echo $read;
pclose($handle);
This snippet reads from stderr. Remove the pipe to read from stdout.