Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 11803

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Gets an SplFileObject object for the file</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="splfileinfo.iswritable.html">SplFileInfo::isWritable</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="splfileinfo.setfileclass.html">SplFileInfo::setFileClass</a></div>
 <div class="up"><a href="class.splfileinfo.html">SplFileInfo</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="splfileinfo.openfile" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SplFileInfo::openFile</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.2)</p><p class="refpurpose"><span class="refname">SplFileInfo::openFile</span> &mdash; <span class="dc-title">Gets an SplFileObject object for the file</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-splfileinfo.openfile-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><a href="class.splfileobject.html" class="type SplFileObject">SplFileObject</a></span> <span class="methodname"><strong>SplFileInfo::openFile</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$open_mode</code><span class="initializer"> = r</span></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$use_include_path</code><span class="initializer"> = false</span></span>
   [, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$context</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
  ]]] )</div>

  <p class="para rdfs-comment">
   Creates an <a href="class.splfileobject.html" class="classname">SplFileObject</a> <span class="type"><a href="language.types.object.html" class="type object">object</a></span> of
   the file. This is useful because <a href="class.splfileobject.html" class="classname">SplFileObject</a>
   contains additional methods for manipulating the file whereas
   <a href="class.splfileinfo.html" class="classname">SplFileInfo</a> is only useful for gaining information,
   like whether the file is writable.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-splfileinfo.openfile-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">open_mode</code></em></span>
     <dd>

      <p class="para">
       The mode for opening the file. See the  <span class="function"><a href="function.fopen.html" class="function">fopen()</a></span>
       documentation for descriptions of possible modes. The default 
       is read only.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">use_include_path</code></em></span>
     <dd>

      <p class="para">
       When set to <strong><code>TRUE</code></strong>, the filename is also
searched for within the <a href="ini.core.html#ini.include-path" class="link">include_path</a>
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">context</code></em></span>
     <dd>

      <p class="para">
       Refer to the <a href="context.html" class="link">context</a>
section of the manual for a description of <em>contexts</em>.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-splfileinfo.openfile-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   The opened file as an <a href="class.splfileobject.html" class="classname">SplFileObject</a> <span class="type"><a href="language.types.object.html" class="type object">object</a></span>.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-splfileinfo.openfile-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   A <a href="class.runtimeexception.html" class="classname">RuntimeException</a> if the file cannot be
   opened (e.g. insufficient access rights).
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-splfileinfo.openfile-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-3942">
    <p><strong>Example #1  <span class="methodname"><strong>SplFileInfo::openFile()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$fileinfo&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SplFileInfo</span><span style="color: #007700">(</span><span style="color: #DD0000">'/tmp/foo.txt'</span><span style="color: #007700">);<br /><br />if&nbsp;(</span><span style="color: #0000BB">$fileinfo</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isWritable</span><span style="color: #007700">())&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$fileobj&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$fileinfo</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">openFile</span><span style="color: #007700">(</span><span style="color: #DD0000">'a'</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$fileobj</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #DD0000">"appended&nbsp;this&nbsp;sample&nbsp;text"</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-splfileinfo.openfile-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="class.splfileobject.html" class="classname">SplFileObject</a></li>
    <li class="member"> <span class="function"><a href="function.stream-context-create.html" class="function" rel="rdfs-seeAlso">stream_context_create()</a> - Creates a stream context</span></li>
    <li class="member"> <span class="function"><a href="function.fopen.html" class="function" rel="rdfs-seeAlso">fopen()</a> - Opens file or URL</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="splfileinfo.iswritable.html">SplFileInfo::isWritable</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="splfileinfo.setfileclass.html">SplFileInfo::setFileClass</a></div>
 <div class="up"><a href="class.splfileinfo.html">SplFileInfo</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>