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

ParameterIs RequiredDescription
commandRequired.Command to execute
modeRequired.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);
?>




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions