Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 3172

php-manual-en-7.2.11-1.mga7.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.1.0)</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>
<code class="parameter">filename</code></dt>

     <dd>

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

    
    
     <dt>
<code class="parameter">flags</code></dt>

     <dd>

      <p class="para">
       The <code class="parameter">flags</code> 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, <span class="function"><strong>dio_open()</strong></span> will 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>
<code class="parameter">mode</code></dt>

     <dd>

      <p class="para">
       If <code class="parameter">flags</code> contains
       <strong><code>O_CREAT</code></strong>, <code class="parameter">mode</code> will
       set the permissions of the file (creation
       permissions). <code class="parameter">mode</code> is required for
       correct operation when <strong><code>O_CREAT</code></strong> is
       specified in <code class="parameter">flags</code> 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>

    
   </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-2831">
   <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>