Latest web development tutorials

PHP popen () function

PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual

Definition and Usage

popen () function uses the command parameter to open the process file pointer.

If an error occurs, the function returns FALSE.

grammar

popen(command,mode)

参数 描述
command 必需。规定要执行的命令。
mode 必需。规定连接模式。

可能的值:

  • r: 只读。
  • w: 只写(打开并清空已有文件或创建一个新文件)


Examples

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


PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual