THE WORLD'S LARGEST WEB DEVELOPER SITE

PHP popen() Function


❮ Complete PHP Filesystem Reference

Definition and Usage

The popen() function opens a pipe to the program specified in the command parameter.

This function returns FALSE if an error occurs.

Syntax

popen(command,mode)

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

Possible values:

  • r: Read only
  • w: Write only (opens and clears existing file or creates a new file)

Example

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

❮ Complete PHP Filesystem Reference