Name
proc_open
Synopsis
resource proc_open(stringcommand
, arraydescriptors
, arraypipes
[, stringdir
[, arrayenv
[, arrayoptions
]]])
Opens a pipe to a process executed by running
command
on the shell, with a variety of
options. The descriptors parameter must be an array with three
elements—in order, they describe the stdin
, stdout
, and stderr
descriptors. For each, specify either
an array containing two elements or a stream resource. In the first
case, if the first element is "pipe"
, the second element is either
"r"
to read from the pipe or
"w"
to write to the pipe. If the
first is "file"
, the second must be
a filename. The pipes
array is filled with
an array of file pointers corresponding to the processes’ descriptors.
If dir
is specified, the process has its
current working directory set to that path. If
env
is specified, the process has its
environment set up with the values from that array. Finally,
options
contains an associative array with
additional options. The following options can be set in the
array:
| If set and true, suppresses errors generated by the process (Windows only). |
| If set and true, bypasses cmd.exe when running the process. |
| If set, specifies the stream context when opening files. |
If any error occurs while attempting to open the process,
false
is returned. If not, the
resource handle for the process is returned.
Get Programming PHP, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.