PHP popen()Functions


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual

Definition and Usage

The popen() function opens a process file pointer using the command parameter.

If an error occurs, the function returns FALSE.

Syntax

popen(command,mode)

Parameters Description
command Required. Specifies the command to execute.
mode Required. Specifies the connection mode.

Possible values:

  • r: Read-only.
  • w: Write-only (opens and truncates an existing file or creates a new file)


Examples

<?php
$file = popen("/bin/ls","r");
//some code to be executed
pclose($file);
?>


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual Other Extensions