Created
February 15, 2015 17:44
-
-
Save rococodogs/46a0c8234e26ad8eb6ee to your computer and use it in GitHub Desktop.
spelling out how to use php's proc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$process = proc_open( | |
'wc', // cmd to run | |
// define yr pipes | |
[ | |
['file', __FILE__, 'r'], // stdin (passing file to wc) | |
['file', 'output.txt' , 'w'] // stdout (output, we could also echo stream_get_contents of $pipes[1]) | |
], | |
// var to store the above | |
$pipes | |
); | |
if ( is_resource($process) ) { | |
// since we don't need to push anything in to stdin, we'll close the process | |
$return = proc_close($process); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment