September 2001
Intermediate to advanced
768 pages
32h 45m
English
resource popen(string command, string mode)
Opens a pipe.
Returns:
File pointer
Description:
This function forks the program specified in command and opens a pipe to it. The pipe can only be unidirectional; that is, only read or write operations are allowed. The returned handle can be treated like a file handle, using fgetss(), fgets(), and fputs(). The mode argument can be either r (read) or w (write).
Warning:
3.0.11: popen() mistakenly renamed to _popen() on Windows, thus issuing error messages when trying to access popen() on Windows machines.
Example:
if(!$fh = popen("/bin/ls", "r")) { echo ("Could not fork ls"); } while(!feof($fh)) { $output = fgets($fh, 1024); echo ("$output<br />"); } pclose($fh); ... |
Read now
Unlock full access