Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 2256

php-manual-en-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>popen</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="index.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"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation 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"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.readfile.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.popen"
></A
>popen</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN26774"
></A
><P
>    (PHP 3, PHP 4 )</P
>popen&nbsp;--&nbsp;Opens process file pointer</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN26777"
></A
><H2
>Description</H2
>resource <B
CLASS="methodname"
>popen</B
> ( string command, string mode)<BR
></BR
><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
>&#13;     If an error occurs, returns <TT
CLASS="constant"
><B
>FALSE</B
></TT
>. 
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
      If you're looking for bi-directional support (two-way), use 
      <A
HREF="function.proc-open.html"
><B
CLASS="function"
>proc_open()</B
></A
>.
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;    <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN26801"
></A
><P
><B
>Example 1. <B
CLASS="function"
>popen()</B
> examole</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;?php
$handle = popen ("/bin/ls", "r");
?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
      If the command to be executed could not be found, a valid
      resource is returned. This may seem odd, but makes sense; it
      allows you to access any error message returned by the shell:
      <DIV
CLASS="informalexample"
><A
NAME="AEN26807"
></A
><P
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;?php
error_reporting(E_ALL);

/* Add redirection so we can get stderr. */
$handle = popen('/path/to/spooge 2&#62;&#38;1', 'r');
echo "'$handle'; " . gettype($handle) . "\n";
$read = fread($handle, 2096);
echo $read;
pclose($handle);
?&#62;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
>
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;     See also <A
HREF="function.pclose.html"
><B
CLASS="function"
>pclose()</B
></A
>, <A
HREF="function.fopen.html"
><B
CLASS="function"
>fopen()</B
></A
>,
     and <A
HREF="function.proc-open.html"
><B
CLASS="function"
>proc_open()</B
></A
>.
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.pclose.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.readfile.html"
ACCESSKEY="N"
>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"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>readfile</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>