<?php
$descs = array(
0 => array( 'pipe' , 'r' ) , #输入
1 => array( 'file' , 'output' , 'w' ) , #输出,可以为管道或文件
2 => array( 'file' , 'errors' , 'w' ) #错误日志,可以为管道或文件
);
$res = proc_open( 'php' , $descs , $pipes );
if( is_resource( $res ) )
{
fputs( $pipes[ 0 ] , '<?php echo \'Hello you!\n\'; ?>' );
fclose( $pipes[ 0 ] );
/**
while( ! feof( $pipes[1] ) )
{
$line = fgets( $pipes[ 1 ] );
echo urlencode( $line );
}
*/
proc_close( $res );
}
?>
$descs三个参数,分别为输入,输出,错误
运行后你会发现目录下多了两个文件, output和error
并且output文件包含Hello you , error文件什么也没有