PHP popen() Function

❮ PHP Filesystem Reference

Example

Open a pipe to the program specified in the command parameter:

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


Definition and Usage

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

Syntax

popen(command, mode)

Parameter Values

Parameter Description
command Required. Specifies the command to execute
mode Required. Specifies the connection mode. Can be "r" (Read only) or "w" (Write only - opens and clears existing file or creates a new file)


Technical Details

Return Value: FALSE on failure
PHP Version: 4.0+

❮ PHP Filesystem Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.