<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="splfileinfo.openfile" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>SplFileInfo::openFile</refname>
  <refpurpose>Gets an SplFileObject object for the file</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis role="SplFileInfo">
   <modifier>public</modifier> <type>SplFileObject</type><methodname>SplFileInfo::openFile</methodname>
   <methodparam choice="opt"><type>string</type><parameter>mode</parameter><initializer>"r"</initializer></methodparam>
   <methodparam choice="opt"><type>bool</type><parameter>useIncludePath</parameter><initializer>&false;</initializer></methodparam>
   <methodparam choice="opt"><type class="union"><type>resource</type><type>null</type></type><parameter>context</parameter><initializer>&null;</initializer></methodparam>
  </methodsynopsis>
  <para>
   Creates an <classname>SplFileObject</classname> <type>object</type> of
   the file. This is useful because <classname>SplFileObject</classname>
   contains additional methods for manipulating the file whereas
   <classname>SplFileInfo</classname> is only useful for gaining information,
   like whether the file is writable.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>mode</parameter></term>
     <listitem>
      <para>
       The mode for opening the file. See the <function>fopen</function>
       documentation for descriptions of possible modes. The default 
       is read only.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>useIncludePath</parameter></term>
     <listitem>
      <para>
       &parameter.use_include_path;
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>context</parameter></term>
     <listitem>
      <para>
       &parameter.context;
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   The opened file as an <classname>SplFileObject</classname> <type>object</type>.
  </para>
 </refsect1>

 <refsect1 role="errors">
  &reftitle.errors;
  <para>
   A <classname>RuntimeException</classname> if the file cannot be
   opened (e.g. insufficient access rights).
  </para>
 </refsect1>

 <refsect1 role="changelog">
  &reftitle.changelog;
  <para>
   <informaltable>
    <tgroup cols="2">
     <thead>
      <row>
       <entry>&Version;</entry>
       <entry>&Description;</entry>
      </row>
     </thead>
     <tbody>
      <row>
       <entry>8.0.0</entry>
       <entry>
        <parameter>context</parameter> is now nullable.
       </entry>
      </row>
     </tbody>
    </tgroup>
   </informaltable>
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title><methodname>SplFileInfo::openFile</methodname> example</title>
    <programlisting role="php">
<![CDATA[
<?php
$fileinfo = new SplFileInfo('/tmp/foo.txt');

if ($fileinfo->isWritable()) {

    $fileobj = $fileinfo->openFile('a');

    $fileobj->fwrite("appended this sample text");
}
?>
]]>
    </programlisting>
   </example>
  </para>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><classname>SplFileObject</classname></member>
    <member><function>stream_context_create</function></member>
    <member><function>fopen</function></member>
   </simplelist>
  </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:"~/.phpdoc/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
-->
