Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

popen()

Example

Open a pipe to the program specified by the command parameter.

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

Definition and Usage

The popen() function creates a pipe to the program specified by the command parameter.

Syntax

popen(commandmode)

Parameter Values

 

Parameter

Description

command

Required. Specifies the command to be executed.

mode

Required. Defines the mode of connection, either “r” (read-only) or “w” (write-only, which opens and clears an existing file or creates a new one).

Technical Details

Return Value:

Returns FALSE on failure.

PHP Version:

4.0+