PHP popen() Function
Definition
The popen() function opens a pipe to the program specified in the command parameter.
Syntax
PHP popen() Function has the following syntax.
popen(command,mode)
Parameter
Parameter | Is Required | Description |
---|---|---|
command | Required. | Command to execute |
mode | Required. | Connection mode. |
Possible values for the mode:
- r: Read only
- w: Write only (opens and clears existing file or creates a new file)
Return
This function returns FALSE if an error occurs.
Example
Opens a pipe to the program specified in the command parameter
<?php/* w w w.j a va 2s . c o m*/
$file = popen("/bin/ls","r");
//some code to be executed
pclose($file);
?>