O'Reilly logo

Programming PHP, 3rd Edition by Peter MacIntyre, Kevin Tatroe, Rasmus Lerdorf

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

proc_open

Synopsis

resource proc_open(string command, array descriptors,
   array pipes[, string dir[, array env[, array options]]])

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:

suppress_errors

If set and true, suppresses errors generated by the process (Windows only).

bypass_shell

If set and true, bypasses cmd.exe when running the process.

context

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required