THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

PHP popen() Function


PHP Filesystem Reference 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);
?>

PHP Filesystem Reference Complete PHP Filesystem Reference