Source of: /manual/en/function.dio-open.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.dio.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'function.dio-open.php',
1 => 'dio_open',
),
'up' =>
array (
0 => 'ref.dio.php',
1 => 'Direct IO Functions',
),
'prev' =>
array (
0 => 'function.dio-fcntl.php',
1 => 'dio_fcntl',
),
'next' =>
array (
0 => 'function.dio-read.php',
1 => 'dio_read',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="function.dio-open" class="refentry">
<div class="refnamediv">
<h1 class="refname">dio_open</h1>
<p class="verinfo">(PHP 4 >= 4.2.0, PHP 5 <= 5.0.5)</p><p class="refpurpose"><span class="refname">dio_open</span> — <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>
<a name="function.dio-open.description"></a><div class="refsect1 description">
<h3 class="title">Description</h3>
<div class="methodsynopsis dc-description">
<span class="type">resource</span> <span class="methodname"><b>dio_open</b></span>
( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$filename</tt></span>
, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$flags</tt></span>
[, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$mode</tt><span class="initializer"> = 0</span></span>
] )</div>
<p class="para rdfs-comment">
<b>dio_open()</b> opens a file and returns a new file
descriptor for it.
</p>
</div>
<a name="function.dio-open.parameters"></a><div class="refsect1 parameters">
<h3 class="title">Parameters</h3>
<p class="para">
</p><dl>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">filename</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
The pathname of the file to open.
</p>
</dd>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">flags</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
The <i><tt class="parameter">flags</tt></i>
parameter is a bitwise-ORed
value comprising flags from the following list. This value
<em class="emphasis">must</em> include one of
<b><tt class="constant">O_RDONLY</tt></b>, <b><tt class="constant">O_WRONLY</tt></b>,
or <b><tt class="constant">O_RDWR</tt></b>. Additionally, it may include
any combination of the other flags from this list.
</p><ul class="itemizedlist">
<li class="listitem">
<p class="para">
<b><tt class="constant">O_RDONLY</tt></b> - opens the file for read access.
</p>
</li>
<li class="listitem">
<p class="para">
<b><tt class="constant">O_WRONLY</tt></b> - opens the file for write access.
</p>
</li>
<li class="listitem">
<p class="para">
<b><tt class="constant">O_RDWR</tt></b> - opens the file for both reading and
writing.
</p>
</li>
<li class="listitem">
<p class="para">
<b><tt class="constant">O_CREAT</tt></b> - creates the file, if it doesn't
already exist.
</p>
</li>
<li class="listitem">
<p class="para">
<b><tt class="constant">O_EXCL</tt></b> - if both <b><tt class="constant">O_CREAT</tt></b>
and <b><tt class="constant">O_EXCL</tt></b> are set and the file already
exists, causes <b>dio_open()</b> to fail.
</p>
</li>
<li class="listitem">
<p class="para">
<b><tt class="constant">O_TRUNC</tt></b> - 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">
<b><tt class="constant">O_APPEND</tt></b> - write operations write data at the
end of the file.
</p>
</li>
<li class="listitem">
<p class="para">
<b><tt class="constant">O_NONBLOCK</tt></b> - sets non blocking mode.
</p>
</li>
<li class="listitem">
<p class="para">
<b><tt class="constant">O_NOCTTY</tt></b> - prevent the OS from
assigning the opened file as the process's controlling
terminal when opening a TTY device file.
</p>
</li>
</ul><p>
</p>
</dd>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">mode</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
If <i><tt class="parameter">flags</tt></i>
contains
<b><tt class="constant">O_CREAT</tt></b>, <i><tt class="parameter">mode</tt></i>
will
set the permissions of the file (creation
permissions). <i><tt class="parameter">Mode</tt></i>
is required for
correct operation when <b><tt class="constant">O_CREAT</tt></b> is
specified in <b><tt class="constant">mode</tt></b> and is ignored
otherwise.
</p>
<p class="para">
The actual permissions assigned to the created file will be
affected by the process's <em class="emphasis">umask</em> setting as
per usual.
</p>
</dd>
</dl>
<p>
</p>
</div>
<a name="function.dio-open.returnvalues"></a><div class="refsect1 returnvalues">
<h3 class="title">Return Values</h3>
<p class="para">
A file descriptor or <b><tt class="constant">FALSE</tt></b> on error.
</p>
</div>
<a name="function.dio-open.examples"></a><div class="refsect1 examples">
<h3 class="title">Examples</h3>
<div class="example">
<p><b>Example #1 Opening a file descriptor</b></p>
<div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /><br />$fd </span><span style="color: #007700">= </span><span style="color: #0000BB">dio_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'/dev/ttyS0'</span><span style="color: #007700">, </span><span style="color: #0000BB">O_RDWR </span><span style="color: #007700">| </span><span style="color: #0000BB">O_NOCTTY </span><span style="color: #007700">| </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">?></span>
</span>
</code></div>
</div>
</div>
</div>
<a name="function.dio-open.seealso"></a><div class="refsect1 seealso">
<h3 class="title">See Also</h3>
<p class="para">
</p><ul class="simplelist">
<li class="member"><a href="function.dio-close.php" class="function" rel="rdfs-seeAlso">dio_close()</a> - Closes the file descriptor given by fd</li>
</ul><p>
</p>
</div>
</div><?php manual_footer(); ?>