<?xml version="1.0" encoding="iso-8859-1"?>
<!-- splitted from ./en/functions/filesystem.xml, last change in rev 1.2 -->
  <refentry id="function.popen">
   <refnamediv>
    <refname>popen</refname>
    <refpurpose>Opens process file pointer</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>popen</methodname>
      <methodparam><type>string</type><parameter>command</parameter></methodparam>
      <methodparam><type>string</type><parameter>mode</parameter></methodparam>
     </methodsynopsis>
    <para> 
     Opens a pipe to a process executed by forking the command given
     by command.
    </para>
    <para> 
     Returns a file pointer identical to that returned by
     <function>fopen</function>, except that it is unidirectional (may
     only be used for reading or writing) and must be closed with
     <function>pclose</function>. This pointer may be used with
     <function>fgets</function>, <function>fgetss</function>, and
     <function>fputs</function>.
    </para>
    <para>
     If an error occurs, returns &false;. 
    </para>
    <para>
     <informalexample>
      <programlisting role="php">
<![CDATA[
$fp = popen ("/bin/ls", "r");
]]>
      </programlisting>
     </informalexample>
    </para>
    <note>
     <para>
      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:
      <informalexample>
       <programlisting role="php">
<![CDATA[
<?php
error_reporting(E_ALL);

/* Add redirection so we can get stderr. */
$fp = popen('/path/to/spooge 2>&1', 'r');
echo "'$fp'; " . gettype($fp) . "\n";
$read = fread($fp, 2096);
echo $read;
pclose($fp);
?>
]]>
       </programlisting>
      </informalexample>
     </para>
    </note>
    <para>
     See also <function>pclose</function>.
    </para>
   </refsect1>
  </refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->