Current Location: Home> Function Categories> popen

popen

Open process file pointer
Name:popen
Category:File system
Programming Language:php
One-line Description:Open a process.

Definition and usage

popen() function opens the process file pointer.

Example

 <?php
$file = popen ( "/bin/ls" , "r" ) ;

//Some code to be executed

pclose ( $file ) ;
?>

grammar

 popen ( command , mode )
parameter describe
Command Required. Specify the orders to be executed.
mode

Required. Specify connection mode.

Possible values:

  • r: Read-only.
  • w: Write only (open and clear existing files or create a new file)

illustrate

Opens a pipeline to a process that is generated by the execution of the derived command command.

Returns the same file pointer as fopen() , except that it is one-way (only for read or write) and must be closed with pclose() . This pointer can be used for fgets() , fgetss() and fwrite() .

If an error occurs, false is returned.

Similar Functions
Popular Articles