Created
August 18, 2012 13:41
-
-
Save yuya-takeyama/3386926 to your computer and use it in GitHub Desktop.
proc_open()'s $cwd argument
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
$ cat proc_open_cwd.php | |
<?php | |
$fdSpecs = array( | |
1 => array('pipe', 'w'), | |
2 => array('pipe', 'w'), | |
); | |
$process = proc_open('php -r "var_dump(getcwd());"', $fdSpecs, $pipes); | |
echo 'Without $cwd argument:', PHP_EOL; | |
echo stream_get_contents($pipes[1]); | |
echo PHP_EOL; | |
$process = proc_open('php -r "var_dump(getcwd());"', $fdSpecs, $pipes, NULL); | |
echo 'With NULL as $cwd argument:', PHP_EOL; | |
echo stream_get_contents($pipes[1]); | |
echo PHP_EOL; | |
$process = proc_open('php -r "var_dump(getcwd());"', $fdSpecs, $pipes, getcwd()); | |
echo 'With getcwd() as $cwd argument:', PHP_EOL; | |
echo stream_get_contents($pipes[1]); | |
echo PHP_EOL; | |
$process = proc_open('php -r "var_dump(getcwd());"', $fdSpecs, $pipes, '/'); | |
echo 'With "/" as $cwd argument:', PHP_EOL; | |
echo stream_get_contents($pipes[1]); |
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 proc_open_cwd.php | |
Without $cwd argument: | |
string(29) "/Users/yuya/dev/php/proc_open" | |
With NULL as $cwd argument: | |
string(29) "/Users/yuya/dev/php/proc_open" | |
With getcwd() as $cwd argument: | |
string(29) "/Users/yuya/dev/php/proc_open" | |
With "/" as $cwd argument: | |
string(1) "/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment