Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 2653

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>Opens a file (creating it if necessary) at a lower level than the
   C library input/ouput stream functions allow.</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.dio-fcntl.html">dio_fcntl</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.dio-read.html">dio_read</a></div>
 <div class="up"><a href="ref.dio.html">Direct IO Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.dio-open" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">dio_open</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5 &lt;= 5.0.5)</p><p class="refpurpose"><span class="refname">dio_open</span> &mdash; <span class="dc-title">
   Opens a file (creating it if necessary) at a lower level than the
   C library input/ouput stream functions allow.
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.dio-open-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><strong>dio_open</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code><span class="initializer"> = 0</span></span>
   ] )</div>

  <p class="para rdfs-comment">
    <span class="function"><strong>dio_open()</strong></span> opens a file and returns a new file
   descriptor for it.  
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.dio-open-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

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

      <p class="para">
       The pathname of the file to open.
      </p>
     </dd>

    </dt>

    <dt>

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

      <p class="para">
       The <em><code class="parameter">flags</code></em> parameter is a bitwise-ORed
       value comprising flags from the following list. This value
       <em class="emphasis">must</em> include one of
       <strong><code>O_RDONLY</code></strong>, <strong><code>O_WRONLY</code></strong>,
       or <strong><code>O_RDWR</code></strong>. Additionally, it may include
       any combination of the other flags from this list.
       <ul class="itemizedlist">
        <li class="listitem">
         <p class="para">
          <strong><code>O_RDONLY</code></strong> - opens the file for read access.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>O_WRONLY</code></strong> - opens the file for write access.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>O_RDWR</code></strong> - opens the file for both reading and
          writing.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>O_CREAT</code></strong> - creates the file, if it doesn&#039;t
          already exist.
         </p>
        </li> 
        <li class="listitem">
         <p class="para">
          <strong><code>O_EXCL</code></strong> - if both <strong><code>O_CREAT</code></strong>
          and <strong><code>O_EXCL</code></strong> are set and the file already
          exists, causes  <span class="function"><strong>dio_open()</strong></span> to fail.
         </p>
        </li> 
        <li class="listitem">
         <p class="para">
          <strong><code>O_TRUNC</code></strong> - if the file exists and is opened 
          for write access, the file will be truncated to zero length.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>O_APPEND</code></strong> - write operations write data at the
          end of the file.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>O_NONBLOCK</code></strong> - sets non blocking mode.
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          <strong><code>O_NOCTTY</code></strong> - prevent the OS from
          assigning the opened file as the process&#039;s controlling
          terminal when opening a TTY device file.
         </p>
        </li>
       </ul>
      </p>
     </dd>

    </dt>

    <dt>

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

      <p class="para">
       If <em><code class="parameter">flags</code></em> contains
       <strong><code>O_CREAT</code></strong>, <em><code class="parameter">mode</code></em> will
       set the permissions of the file (creation
       permissions). <em><code class="parameter">Mode</code></em> is required for
       correct operation when <strong><code>O_CREAT</code></strong> is
       specified in <strong><code>mode</code></strong> and is ignored
       otherwise.
      </p>
      <p class="para">
       The actual permissions assigned to the created file will be
       affected by the process&#039;s <em class="emphasis">umask</em> setting as
       per usual.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.dio-open-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   A file descriptor or <strong><code>FALSE</code></strong> on error.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.dio-open-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-2330">
   <p><strong>Example #1 Opening a file descriptor</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$fd&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dio_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'/dev/ttyS0'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">O_RDWR&nbsp;</span><span style="color: #007700">|&nbsp;</span><span style="color: #0000BB">O_NOCTTY&nbsp;</span><span style="color: #007700">|&nbsp;</span><span style="color: #0000BB">O_NONBLOCK</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">dio_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>    
 </div>

 <div class="refsect1 seealso" id="refsect1-function.dio-open-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.dio-close.html" class="function" rel="rdfs-seeAlso">dio_close()</a> - Closes the file descriptor given by fd</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="function.dio-fcntl.html">dio_fcntl</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.dio-read.html">dio_read</a></div>
 <div class="up"><a href="ref.dio.html">Direct IO Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>