<HTML ><HEAD ><TITLE >popen</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK REL="HOME" TITLE="PHP Manual" HREF="manual.html"><LINK REL="UP" TITLE="Filesystem functions" HREF="ref.filesystem.html"><LINK REL="PREVIOUS" TITLE="pclose" HREF="function.pclose.html"><LINK REL="NEXT" TITLE="readfile" HREF="function.readfile.html"></HEAD ><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.pclose.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.readfile.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.popen" >popen</A ></H1 ><DIV CLASS="refnamediv" ><A NAME="AEN9195" ></A >popen -- Open process file pointer</DIV ><DIV CLASS="refsect1" ><A NAME="AEN9198" ></A ><H2 >Description</H2 ><DIV CLASS="funcsynopsis" ><P ></P ><CODE CLASS="FUNCDEF" >int popen</CODE >(string command, string mode);<P ></P ></DIV ><P > Opens a pipe to a process executed by forking the command given by command. </P ><P > Returns a file pointer identical to that returned by <A HREF="function.fopen.html" ><B CLASS="function" >fopen()</B ></A >, except that it is unidirectional (may only be used for reading or writing) and must be closed with <A HREF="function.pclose.html" ><B CLASS="function" >pclose()</B ></A >. This pointer may be used with <A HREF="function.fgets.html" ><B CLASS="function" >fgets()</B ></A >, <A HREF="function.fgetss.html" ><B CLASS="function" >fgetss()</B ></A >, and <A HREF="function.fputs.html" ><B CLASS="function" >fputs()</B ></A >. </P ><P > If an error occurs, returns false. </P ><P > <DIV CLASS="informalexample" ><P ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="programlisting" > 1 2 $fp = popen ("/bin/ls", "r"); 3 </PRE ></TD ></TR ></TABLE ><P ></P ></DIV > </P ><P > See also <A HREF="function.pclose.html" ><B CLASS="function" >pclose()</B ></A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.pclose.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="manual.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.readfile.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >pclose</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.filesystem.html" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >readfile</TD ></TR ></TABLE ></DIV ></BODY ></HTML >