2001-08-19 11:42:10 +00:00
|
|
|
<?xml encoding="iso-8859-1"?>
|
2001-09-21 22:47:49 +00:00
|
|
|
<!-- $Revision: 1.81 $ -->
|
1999-06-06 18:51:02 +00:00
|
|
|
<reference id="ref.filesystem">
|
1999-06-20 03:04:56 +00:00
|
|
|
<title>Filesystem functions</title>
|
1999-06-06 18:51:02 +00:00
|
|
|
<titleabbrev>Filesystem</titleabbrev>
|
|
|
|
|
|
|
|
<refentry id="function.basename">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>basename</refname>
|
1999-12-21 00:24:24 +00:00
|
|
|
<refpurpose>
|
2000-08-15 21:19:54 +00:00
|
|
|
Returns filename component of path
|
1999-12-21 00:24:24 +00:00
|
|
|
</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>string <function>basename</function></funcdef>
|
|
|
|
<paramdef>string <parameter>path</parameter></paramdef>
|
2001-06-23 00:56:33 +00:00
|
|
|
<paramdef>string <parameter><optional>suffix</optional></parameter></paramdef>
|
2000-06-24 07:38:45 +00:00
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Given a string containing a path to a file, this function will
|
1999-12-20 22:26:22 +00:00
|
|
|
return the base name of the file.
|
2001-06-23 00:56:33 +00:00
|
|
|
If the filename ends in <parameter>suffix</parameter> this will
|
2001-06-23 01:57:14 +00:00
|
|
|
also be cut off (the <parameter>suffix</parameter> parameter was added
|
2001-06-23 01:09:51 +00:00
|
|
|
in PHP 4.0.7).
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
On Windows, both slash (<literal>/</literal>) and backslash
|
|
|
|
(<literal>\</literal>) are used as path separator character. In
|
|
|
|
other environments, it is the forward slash
|
1999-12-20 22:26:22 +00:00
|
|
|
(<literal>/</literal>).
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
<example>
|
|
|
|
<title><function>basename</function> example</title>
|
|
|
|
<programlisting role="php">
|
1999-06-06 18:51:02 +00:00
|
|
|
$path = "/home/httpd/html/index.php3";
|
2000-08-15 21:19:54 +00:00
|
|
|
$file = basename ($path); // $file is set to "index.php3"
|
2001-06-23 00:56:33 +00:00
|
|
|
$file = basename ($path,".php3"); // $file is set to "index"
|
1999-12-20 22:26:22 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
See also: <function>dirname</function>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.chgrp">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>chgrp</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Changes file group</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>chgrp</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
<paramdef>mixed <parameter>group</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-08-12 23:43:38 +00:00
|
|
|
Attempts to change the group of the file
|
2000-08-15 21:19:54 +00:00
|
|
|
<parameter>filename</parameter> to
|
|
|
|
<parameter>group</parameter>. Only the superuser may change the
|
|
|
|
group of a file arbitrarily; other users may change the group of
|
|
|
|
a file to any group of which that user is a member.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; on success; otherwise returns &false;.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
See also <function>chown</function> and
|
|
|
|
<function>chmod</function>.
|
|
|
|
</para>
|
2000-02-25 00:02:34 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
2000-08-15 21:19:54 +00:00
|
|
|
This function does not work on Windows systems
|
2000-02-25 00:02:34 +00:00
|
|
|
</simpara>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.chmod">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>chmod</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Changes file mode</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>chmod</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>mode</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Attempts to change the mode of the file specified by
|
|
|
|
<parameter>filename</parameter> to that given in
|
1999-12-20 22:26:22 +00:00
|
|
|
<parameter>mode</parameter>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
Note that <parameter>mode</parameter> is not automatically
|
2000-08-12 23:43:38 +00:00
|
|
|
assumed to be an octal value, so strings (such as "g+w") will
|
|
|
|
not work properly. To ensure the expected operation,
|
1999-06-06 18:51:02 +00:00
|
|
|
you need to prefix <parameter>mode</parameter> with a zero (0):
|
|
|
|
<informalexample>
|
1999-12-20 22:26:22 +00:00
|
|
|
<programlisting role="php">
|
2000-08-19 04:05:09 +00:00
|
|
|
chmod ("/somedir/somefile", 755); // decimal; probably incorrect
|
|
|
|
chmod ("/somedir/somefile", "u+rwx,go+rx"); // string; incorrect
|
2000-08-15 21:19:54 +00:00
|
|
|
chmod ("/somedir/somefile", 0755); // octal; correct value of mode
|
1999-06-06 18:51:02 +00:00
|
|
|
</programlisting>
|
1999-12-20 22:26:22 +00:00
|
|
|
</informalexample>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; on success and &false; otherwise.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
See also <function>chown</function> and
|
|
|
|
<function>chgrp</function>.
|
|
|
|
</para>
|
2000-02-25 00:02:34 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
2000-08-15 21:19:54 +00:00
|
|
|
This function does not work on Windows systems
|
2000-02-25 00:02:34 +00:00
|
|
|
</simpara>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.chown">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>chown</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Changes file owner</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>chown</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
<paramdef>mixed <parameter>user</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Attempts to change the owner of the file filename to user
|
1999-12-20 22:26:22 +00:00
|
|
|
user. Only the superuser may change the owner of a file.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; on success; otherwise returns &false;.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
See also <function>chown</function> and
|
|
|
|
<function>chmod</function>.
|
|
|
|
</para>
|
2000-02-25 00:02:34 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
|
|
|
This function does not work on Windows systems
|
|
|
|
</simpara>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.clearstatcache">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>clearstatcache</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Clears file stat cache</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>void <function>clearstatcache</function></funcdef>
|
|
|
|
<void/>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
1999-06-19 01:09:52 +00:00
|
|
|
Invoking the <systemitem>stat</systemitem> or
|
1999-12-20 22:26:22 +00:00
|
|
|
<systemitem>lstat</systemitem> system call on most systems is
|
|
|
|
quite expensive. Therefore, the result of the last call to any of
|
|
|
|
the status functions (listed below) is stored for use on the next
|
1999-06-06 18:51:02 +00:00
|
|
|
such call using the same filename. If you wish to force a new
|
|
|
|
status check, for instance if the file is being checked many
|
|
|
|
times and may change or disappear, use this function to clear the
|
1999-12-20 22:26:22 +00:00
|
|
|
results of the last call from memory.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
This value is only cached for the lifetime of a single request.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
Affected functions include <function>stat</function>,
|
|
|
|
<function>lstat</function>,
|
|
|
|
<function>file_exists</function>,
|
2001-01-03 19:17:46 +00:00
|
|
|
<function>is_writable</function>,
|
1999-06-06 18:51:02 +00:00
|
|
|
<function>is_readable</function>,
|
|
|
|
<function>is_executable</function>,
|
|
|
|
<function>is_file</function>,
|
|
|
|
<function>is_dir</function>,
|
|
|
|
<function>is_link</function>,
|
|
|
|
<function>filectime</function>,
|
|
|
|
<function>fileatime</function>,
|
|
|
|
<function>filemtime</function>,
|
|
|
|
<function>fileinode</function>,
|
|
|
|
<function>filegroup</function>,
|
|
|
|
<function>fileowner</function>,
|
|
|
|
<function>filesize</function>,
|
|
|
|
<function>filetype</function>, and
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>fileperms</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.copy">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>copy</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Copies file</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>copy</function></funcdef>
|
|
|
|
<paramdef>string <parameter>source</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>dest</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Makes a copy of a file. Returns &true; if the copy succeeded,
|
|
|
|
&false; otherwise.
|
1999-12-20 22:26:22 +00:00
|
|
|
<example>
|
2001-06-23 20:10:52 +00:00
|
|
|
<title><function>copy</function> example</title>
|
1999-12-20 22:26:22 +00:00
|
|
|
<programlisting role="php">
|
2000-08-15 21:19:54 +00:00
|
|
|
if (!copy($file, $file.'.bak')) {
|
|
|
|
print ("failed to copy $file...<br>\n");
|
1999-06-06 18:51:02 +00:00
|
|
|
}
|
1999-12-20 22:26:22 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
See also: <function>rename</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.delete">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>delete</refname>
|
1999-12-21 00:24:24 +00:00
|
|
|
<refpurpose>A dummy manual entry</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>void <function>delete</function></funcdef>
|
|
|
|
<paramdef>string <parameter>file</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
2000-08-15 21:19:54 +00:00
|
|
|
<para>
|
|
|
|
This is a dummy manual entry to satisfy those people who are
|
|
|
|
looking for <function>unlink</function> or
|
|
|
|
<function>unset</function> in the wrong place.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also: <function>unlink</function> to delete files,
|
|
|
|
<function>unset</function> to delete variables.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.dirname">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>dirname</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Returns directory name component of path</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>string <function>dirname</function></funcdef>
|
|
|
|
<paramdef>string <parameter>path</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Given a string containing a path to a file, this function will
|
1999-10-20 22:41:42 +00:00
|
|
|
return the name of the directory.</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
On Windows, both slash (<literal>/</literal>) and backslash
|
|
|
|
(<literal>\</literal>) are used as path separator character. In
|
|
|
|
other environments, it is the forward slash
|
1999-10-20 22:41:42 +00:00
|
|
|
(<literal>/</literal>).</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
<example>
|
2001-06-23 20:10:52 +00:00
|
|
|
<title><function>dirname</function> example</title>
|
1999-12-20 22:26:22 +00:00
|
|
|
<programlisting role="php">
|
1999-06-06 18:51:02 +00:00
|
|
|
$path = "/etc/passwd";
|
2000-08-15 21:19:54 +00:00
|
|
|
$file = dirname ($path); // $file is set to "/etc"
|
1999-12-20 22:26:22 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
See also: <function>basename</function>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.diskfreespace">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>diskfreespace</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Returns available space in directory</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>float <function>diskfreespace</function></funcdef>
|
|
|
|
<paramdef>string <parameter>directory</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
Given a string containing a directory, this function will return
|
2000-08-12 23:57:21 +00:00
|
|
|
the number of bytes available on the corresponding filesystem or
|
|
|
|
disk partition.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
<example>
|
|
|
|
<title><function>diskfreespace</function> example</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
$df = diskfreespace("/"); // $df contains the number of bytes
|
|
|
|
// available on "/"
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2001-05-15 23:51:56 +00:00
|
|
|
<refentry id="function.disk-total-space">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>disk_total_space</refname>
|
|
|
|
<refpurpose>Returns the total size of a directory</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>float <function>disk_total_space</function></funcdef>
|
|
|
|
<paramdef>string <parameter>directory</parameter></paramdef>
|
|
|
|
</funcprototype>
|
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Given a string containing a directory, this function will return
|
|
|
|
the total number of bytes on the corresponding filesystem or disk
|
|
|
|
partition.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>disk_total_space</function> example</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
$df = disk_total_space("/"); // $df contains the total number of
|
|
|
|
// bytes available on "/"
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
1999-06-06 18:51:02 +00:00
|
|
|
<refentry id="function.fclose">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fclose</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Closes an open file pointer</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
2001-05-11 10:16:19 +00:00
|
|
|
<funcdef>bool <function>fclose</function></funcdef>
|
2000-06-24 07:38:45 +00:00
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-05-11 10:16:19 +00:00
|
|
|
The file pointed to by <parameter>fp</parameter> is closed.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; on success and &false;
|
2001-05-11 10:16:19 +00:00
|
|
|
on failure.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The file pointer must be valid, and must point to a file
|
|
|
|
successfully opened by <function>fopen</function> or
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>fsockopen</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.feof">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>feof</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Tests for end-of-file on a file pointer</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>feof</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; if the file pointer is at EOF or an error occurs;
|
|
|
|
otherwise returns &false;.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The file pointer must be valid, and must point to a file
|
|
|
|
successfully opened by <function>fopen</function>,
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>popen</function>, or <function>fsockopen</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2000-11-01 21:55:46 +00:00
|
|
|
<refentry id="function.fflush">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fflush</refname>
|
|
|
|
<refpurpose>Flushes the output to a file</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>fflush</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
</funcprototype>
|
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
This function forces a write of all buffered output to the
|
|
|
|
to the resource pointed to by the file handle
|
2001-07-07 21:57:31 +00:00
|
|
|
<parameter>fp</parameter>. Returns &true; if succesful, &false;
|
2000-11-01 21:55:46 +00:00
|
|
|
otherwise.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
The file pointer must be valid, and must point to a file
|
|
|
|
successfully opened by <function>fopen</function>,
|
|
|
|
<function>popen</function>, or <function>fsockopen</function>.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
1999-06-06 18:51:02 +00:00
|
|
|
<refentry id="function.fgetc">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fgetc</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Gets character from file pointer</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>string <function>fgetc</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Returns a string containing a single character read from the
|
2001-07-07 18:42:46 +00:00
|
|
|
file pointed to by fp. Returns &false; on EOF.
|
2000-08-27 11:22:21 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The file pointer must be valid, and must point to a file
|
|
|
|
successfully opened by <function>fopen</function>,
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>popen</function>, or <function>fsockopen</function>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>fread</function>, <function>fopen</function>,
|
|
|
|
<function>popen</function>, <function>fsockopen</function>, and
|
|
|
|
<function>fgets</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.fgetcsv">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fgetcsv</refname>
|
1999-12-20 22:26:22 +00:00
|
|
|
<refpurpose>
|
2000-08-15 21:19:54 +00:00
|
|
|
Gets line from file pointer and parse for CSV fields
|
1999-12-20 22:26:22 +00:00
|
|
|
</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>array <function>fgetcsv</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>length</parameter></paramdef>
|
|
|
|
<paramdef>string
|
|
|
|
<parameter>
|
|
|
|
<optional>delimiter</optional>
|
|
|
|
</parameter>
|
|
|
|
</paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
2000-08-15 21:19:54 +00:00
|
|
|
Similar to <function>fgets</function> except that
|
|
|
|
<function>fgetcsv</function> parses the line it reads for fields
|
|
|
|
in <acronym>CSV</acronym> format and returns an array containing
|
|
|
|
the fields read. The field delimiter is a comma, unless you
|
2000-09-10 11:14:16 +00:00
|
|
|
specify another delimiter with the optional third parameter.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
2000-08-15 21:19:54 +00:00
|
|
|
<parameter>Fp</parameter> must be a valid file pointer to a file
|
|
|
|
successfully opened by <function>fopen</function>,
|
|
|
|
<function>popen</function>, or <function>fsockopen</function>
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
|
|
|
<simpara>
|
2000-08-15 21:19:54 +00:00
|
|
|
Length must be greater than the longest line to be found in the
|
1999-12-20 22:26:22 +00:00
|
|
|
CSV file (allowing for trailing line-end characters).
|
|
|
|
</simpara>
|
|
|
|
<simpara>
|
2001-07-07 18:42:46 +00:00
|
|
|
<function>fgetcsv</function> returns &false; on error, including
|
2000-08-15 21:19:54 +00:00
|
|
|
end of file.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
|
|
|
<simpara>
|
2000-09-10 11:14:16 +00:00
|
|
|
N.B. A blank line in a CSV file will be returned as an array
|
2001-07-07 18:42:46 +00:00
|
|
|
comprising a single &null; field, and will not be treated as an
|
2000-09-10 11:14:16 +00:00
|
|
|
error.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
|
|
|
<example>
|
|
|
|
<title>
|
2001-06-23 20:10:52 +00:00
|
|
|
<function>fgetcsv</function> example - Read and print entire
|
1999-12-20 22:26:22 +00:00
|
|
|
contents of a CSV file
|
|
|
|
</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
$row = 1;
|
|
|
|
$fp = fopen ("test.csv","r");
|
|
|
|
while ($data = fgetcsv ($fp, 1000, ",")) {
|
|
|
|
$num = count ($data);
|
2000-07-08 10:52:08 +00:00
|
|
|
print "<p> $num fields in line $row: <br>";
|
1999-12-20 22:26:22 +00:00
|
|
|
$row++;
|
2000-07-08 10:52:08 +00:00
|
|
|
for ($c=0; $c<$num; $c++) {
|
|
|
|
print $data[$c] . "<br>";
|
1999-12-20 22:26:22 +00:00
|
|
|
}
|
1999-06-06 18:51:02 +00:00
|
|
|
}
|
1999-12-20 22:26:22 +00:00
|
|
|
fclose ($fp);
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.fgets">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fgets</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Gets line from file pointer</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>string <function>fgets</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>length</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Returns a string of up to length - 1 bytes read from the file
|
|
|
|
pointed to by fp. Reading ends when length - 1 bytes have been
|
1999-12-20 22:26:22 +00:00
|
|
|
read, on a newline (which is included in the return value), or on
|
|
|
|
EOF (whichever comes first).
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
If an error occurs, returns &false;.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
Common Pitfalls:
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
1999-12-20 22:26:22 +00:00
|
|
|
People used to the 'C' semantics of fgets should note the
|
|
|
|
difference in how EOF is returned.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
1999-12-20 22:26:22 +00:00
|
|
|
The file pointer must be valid, and must point to a file
|
1999-06-06 18:51:02 +00:00
|
|
|
successfully opened by <function>fopen</function>,
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>popen</function>, or
|
|
|
|
<function>fsockopen</function>.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
A simple example follows:
|
|
|
|
<example>
|
1999-06-06 18:51:02 +00:00
|
|
|
<title>Reading a file line by line</title>
|
1999-10-20 22:41:42 +00:00
|
|
|
<programlisting role="php">
|
1999-12-20 22:26:22 +00:00
|
|
|
$fd = fopen ("/tmp/inputfile.txt", "r");
|
2000-08-15 21:19:54 +00:00
|
|
|
while (!feof ($fd)) {
|
1999-12-20 22:26:22 +00:00
|
|
|
$buffer = fgets($fd, 4096);
|
|
|
|
echo $buffer;
|
1999-06-06 18:51:02 +00:00
|
|
|
}
|
1999-12-20 22:26:22 +00:00
|
|
|
fclose ($fd);
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>fread</function>, <function>fopen</function>,
|
2000-08-23 07:32:13 +00:00
|
|
|
<function>popen</function>, <function>fgetc</function>,
|
|
|
|
<function>fsockopen</function>, and
|
|
|
|
<function>socket_set_timeout</function>.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.fgetss">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fgetss</refname>
|
1999-12-21 00:24:24 +00:00
|
|
|
<refpurpose>
|
2000-08-15 21:19:54 +00:00
|
|
|
Gets line from file pointer and strip HTML tags
|
1999-12-21 00:24:24 +00:00
|
|
|
</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>string <function>fgetss</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>length</parameter></paramdef>
|
|
|
|
<paramdef>string
|
|
|
|
<parameter>
|
|
|
|
<optional>allowable_tags</optional>
|
|
|
|
</parameter>
|
|
|
|
</paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
Identical to <function>fgets</function>, except that fgetss
|
|
|
|
attempts to strip any HTML and PHP tags from the text it
|
|
|
|
reads.
|
|
|
|
</para>
|
1999-09-23 08:49:02 +00:00
|
|
|
<para>
|
|
|
|
You can use the optional third parameter to specify tags which
|
|
|
|
should not be stripped.
|
1999-12-20 22:26:22 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
<parameter>allowable_tags</parameter> was added in PHP 3.0.13,
|
|
|
|
PHP4B3.
|
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
See also <function>fgets</function>, <function>fopen</function>,
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>fsockopen</function>, <function>popen</function>, and
|
|
|
|
<function>strip_tags</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.file">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>file</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Reads entire file into an array</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>array <function>file</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
<paramdef>int
|
|
|
|
<parameter><optional>use_include_path</optional></parameter>
|
|
|
|
</paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
Identical to <function>readfile</function>, except that
|
|
|
|
<function>file</function> returns the file in an array. Each
|
|
|
|
element of the array corresponds to a line in the file, with the
|
|
|
|
newline still attached.
|
|
|
|
</para>
|
1999-09-07 09:23:47 +00:00
|
|
|
<para>
|
|
|
|
You can use the optional second parameter and set it to "1", if
|
1999-12-20 22:26:22 +00:00
|
|
|
you want to search for the file in the <link
|
|
|
|
linkend="ini.include-path">include_path</link>, too.
|
|
|
|
</para>
|
2000-01-26 20:43:34 +00:00
|
|
|
<para>
|
|
|
|
<informalexample>
|
2000-08-15 21:19:54 +00:00
|
|
|
<programlisting role="php">
|
2000-01-26 20:43:34 +00:00
|
|
|
<?php
|
2000-01-26 20:58:36 +00:00
|
|
|
// get a web page into an array and print it out
|
2000-08-15 21:19:54 +00:00
|
|
|
$fcontents = file ('http://www.php.net');
|
|
|
|
while (list ($line_num, $line) = each ($fcontents)) {
|
|
|
|
echo "<b>Line $line_num:</b> " . htmlspecialchars ($line) . "<br>\n";
|
2000-01-26 20:58:36 +00:00
|
|
|
}
|
2000-01-26 20:43:34 +00:00
|
|
|
|
|
|
|
// get a web page into a string
|
2000-08-15 21:19:54 +00:00
|
|
|
$fcontents = join ('', file ('http://www.php.net'));
|
2000-01-26 20:43:34 +00:00
|
|
|
?>
|
|
|
|
</programlisting>
|
|
|
|
</informalexample>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
See also <function>readfile</function>,
|
2000-08-23 07:32:13 +00:00
|
|
|
<function>fopen</function>, <function>fsockopen</function>, and
|
|
|
|
<function>popen</function>.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2000-01-26 20:43:34 +00:00
|
|
|
|
1999-06-06 18:51:02 +00:00
|
|
|
<refentry id="function.file-exists">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>file_exists</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Checks whether a file exists</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
2000-08-27 11:39:39 +00:00
|
|
|
<funcdef>bool <function>file_exists</function></funcdef>
|
2000-06-24 07:38:45 +00:00
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; if the file specified by
|
|
|
|
<parameter>filename</parameter> exists; &false; otherwise.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
2000-01-26 22:33:42 +00:00
|
|
|
<simpara>
|
2001-03-26 23:39:25 +00:00
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
2000-01-26 22:33:42 +00:00
|
|
|
</simpara>
|
|
|
|
<simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
The results of this function are cached. See
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
2000-01-26 22:33:42 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2000-01-26 22:33:42 +00:00
|
|
|
|
1999-06-06 18:51:02 +00:00
|
|
|
<refentry id="function.fileatime">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fileatime</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Gets last access time of file</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>fileatime</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
2000-01-27 02:44:48 +00:00
|
|
|
<simpara>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns the time the file was last accessed, or &false; in case of
|
2000-01-27 02:44:48 +00:00
|
|
|
an error. The time is returned as a Unix timestamp.
|
|
|
|
</simpara>
|
|
|
|
<simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
The results of this function are cached. See
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
2000-01-27 02:44:48 +00:00
|
|
|
</simpara>
|
2000-08-15 20:22:01 +00:00
|
|
|
<simpara>
|
|
|
|
Note: The atime of a file is supposed to change whenever
|
|
|
|
the data blocks of a file are being read. This can be
|
2001-03-26 23:46:08 +00:00
|
|
|
costly performancewise when an application regularly
|
2000-08-15 20:22:01 +00:00
|
|
|
accesses a very large number of files or directories. Some
|
|
|
|
Unix filesystems can be mounted with atime updates disabled
|
|
|
|
to increase the performance of such applications; USENET
|
|
|
|
news spools are a common example. On such filesystems
|
|
|
|
this function will be useless.
|
|
|
|
</simpara>
|
2001-03-26 23:39:25 +00:00
|
|
|
<simpara>
|
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.filectime">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>filectime</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Gets inode change time of file</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>filectime</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns the time the file was last changed, or &false; in case of
|
2000-01-27 02:44:48 +00:00
|
|
|
an error. The time is returned as a Unix timestamp.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
2001-03-26 23:44:33 +00:00
|
|
|
<para>
|
|
|
|
Note: In most Unix filesystems, a file is considered
|
|
|
|
changed when its inode data is changed; that is, when
|
|
|
|
the permissions, owner, group, or other metadata
|
|
|
|
from the inode is updated. See also
|
|
|
|
<function>filemtime</function> (which is what you want to use
|
2000-08-15 20:22:01 +00:00
|
|
|
when you want to create "Last Modified" footers on web pages) and
|
2000-08-15 21:19:54 +00:00
|
|
|
<function>fileatime</function>.
|
2000-08-15 20:22:01 +00:00
|
|
|
</para>
|
2001-03-26 23:44:33 +00:00
|
|
|
<para>Note also that in some Unix texts the ctime of a file is
|
|
|
|
referred to as being the creation time of the file. This is wrong.
|
|
|
|
There is no creation time for Unix files in most Unix filesystems.
|
2000-08-15 20:22:01 +00:00
|
|
|
</para>
|
2001-03-26 23:39:25 +00:00
|
|
|
<simpara>
|
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.filegroup">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>filegroup</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Gets file group</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>filegroup</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
1999-12-20 22:26:22 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns the group ID of the owner of the file, or &false; in case
|
2000-01-11 03:52:08 +00:00
|
|
|
of an error. The group ID is returned in numerical format, use
|
|
|
|
<function>posix_getgrgid</function> to resolve it to a group name.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
2000-02-25 00:02:34 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
|
|
|
This function does not work on Windows systems
|
|
|
|
</simpara>
|
2001-03-26 23:39:25 +00:00
|
|
|
<simpara>
|
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
|
|
|
</simpara>
|
2000-02-25 00:02:34 +00:00
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.fileinode">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fileinode</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Gets file inode</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>fileinode</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
1999-08-25 12:36:16 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns the inode number of the file, or &false; in case of an
|
1999-10-20 22:41:42 +00:00
|
|
|
error.</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
2001-03-26 23:39:25 +00:00
|
|
|
<simpara>
|
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
|
|
|
</simpara>
|
2000-02-25 00:02:34 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
|
|
|
This function does not work on Windows systems
|
|
|
|
</simpara>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.filemtime">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>filemtime</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Gets file modification time</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>filemtime</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
1999-08-25 12:36:16 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns the time the file was last modified, or &false; in case of
|
2000-01-27 02:44:48 +00:00
|
|
|
an error. The time is returned as a Unix timestamp.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
2001-03-26 23:50:26 +00:00
|
|
|
<simpara>
|
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
|
|
|
</simpara>
|
2000-08-15 20:22:01 +00:00
|
|
|
<para>Note: This function returns the time when the data
|
|
|
|
blocks of a file were being written to, that is, the time
|
|
|
|
when the content of the file was changed. Use
|
2000-08-15 21:19:54 +00:00
|
|
|
<function>date</function> on the result of this function
|
2000-08-15 20:22:01 +00:00
|
|
|
to get a printable modification date for use in page footers.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.fileowner">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fileowner</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Gets file owner</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>fileowner</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
1999-12-20 22:26:22 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns the user ID of the owner of the file, or &false; in case of
|
2000-01-11 03:52:08 +00:00
|
|
|
an error. The user ID is returned in numerical format, use
|
|
|
|
<function>posix_getpwuid</function> to resolve it to a username.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-06-15 20:59:47 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
2001-03-26 23:39:25 +00:00
|
|
|
<simpara>
|
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
|
|
|
</simpara>
|
2000-02-25 00:02:34 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
|
|
|
This function does not work on Windows systems
|
|
|
|
</simpara>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.fileperms">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fileperms</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Gets file permissions</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>fileperms</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
1999-06-15 20:59:47 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns the permissions on the file, or &false; in case of an error.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
2001-03-26 23:39:25 +00:00
|
|
|
<simpara>
|
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.filesize">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>filesize</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Gets file size</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>filesize</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
1999-12-20 22:26:22 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns the size of the file, or &false; in case of an error.
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
2001-03-26 23:39:25 +00:00
|
|
|
<simpara>
|
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.filetype">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>filetype</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Gets file type</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>string <function>filetype</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
1999-12-20 22:26:22 +00:00
|
|
|
<para>
|
|
|
|
Returns the type of the file. Possible values are fifo, char,
|
2001-07-07 21:57:31 +00:00
|
|
|
dir, block, link, file, and unknown.</para> <para> Returns &false;
|
1999-12-20 22:26:22 +00:00
|
|
|
if an error occurs.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
2001-03-26 23:39:25 +00:00
|
|
|
<simpara>
|
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.flock">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>flock</refname>
|
1999-12-21 00:24:24 +00:00
|
|
|
<refpurpose>Portable advisory file locking</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>bool <function>flock</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>operation</parameter></paramdef>
|
|
|
|
<paramdef>int
|
|
|
|
<parameter>
|
|
|
|
<optional>wouldblock</optional>
|
|
|
|
</parameter>
|
|
|
|
</paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
1999-12-20 22:26:22 +00:00
|
|
|
PHP supports a portable way of locking complete files in an
|
|
|
|
advisory way (which means all accessing programs have to use the
|
|
|
|
same way of locking or it will not work).
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
1999-12-21 00:24:24 +00:00
|
|
|
<function>flock</function> operates on <parameter>fp</parameter>
|
|
|
|
which must be an open file
|
|
|
|
pointer. <parameter>operation</parameter> is one of the following
|
|
|
|
values:
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
<itemizedlist>
|
1999-12-20 22:26:22 +00:00
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2000-11-01 22:41:01 +00:00
|
|
|
To acquire a shared lock (reader), set
|
|
|
|
<parameter>operation</parameter> to LOCK_SH (set to 1 prior to
|
|
|
|
PHP 4.0.1).
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2000-11-01 22:41:01 +00:00
|
|
|
To acquire an exclusive lock (writer), set
|
|
|
|
<parameter>operation</parameter> to LOCK_EX (set to 2 prior to
|
|
|
|
PHP 4.0.1).
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2000-11-01 22:41:01 +00:00
|
|
|
To release a lock (shared or exclusive), set
|
|
|
|
<parameter>operation</parameter> to LOCK_UN (set to 3 prior to
|
|
|
|
PHP 4.0.1).
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2000-11-01 22:41:01 +00:00
|
|
|
If you don't want <function>flock</function> to block while
|
|
|
|
locking, add LOCK_NB (4 prior to PHP 4.0.1) to
|
|
|
|
<parameter>operation</parameter>.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
1999-06-06 18:51:02 +00:00
|
|
|
</itemizedlist>
|
|
|
|
</para>
|
|
|
|
<simpara>
|
2001-06-23 20:10:52 +00:00
|
|
|
<function>flock</function> allows you to perform a simple
|
1999-12-20 22:26:22 +00:00
|
|
|
reader/writer model which can be used on virtually every platform
|
2000-08-15 21:19:54 +00:00
|
|
|
(including most Unices and even Windows). The optional 3rd
|
2001-07-07 18:42:46 +00:00
|
|
|
argument is set to &true; if the lock would block (EWOULDBLOCK
|
2000-08-15 21:19:54 +00:00
|
|
|
errno condition)
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
2001-07-07 18:42:46 +00:00
|
|
|
<function>flock</function> returns &true; on success and &false; on
|
1999-12-20 22:26:22 +00:00
|
|
|
error (e.g. when a lock could not be acquired).
|
|
|
|
</simpara>
|
2000-10-19 13:11:07 +00:00
|
|
|
<warning>
|
|
|
|
<para>
|
|
|
|
On most operation systems <function>flock</function> is implemented
|
|
|
|
at the process level. When using a multithreaded server API like
|
|
|
|
ISAPI you cannot rely on <function>flock</function> to protect
|
|
|
|
files against other PHP scripts running in parallel threads of the
|
|
|
|
same server instance!
|
|
|
|
</para>
|
|
|
|
</warning>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.fopen">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fopen</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Opens file or URL</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>fopen</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>mode</parameter></paramdef>
|
|
|
|
<paramdef>int
|
|
|
|
<parameter>
|
|
|
|
<optional>use_include_path</optional>
|
|
|
|
</parameter>
|
|
|
|
</paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
1999-12-20 22:26:22 +00:00
|
|
|
If <parameter>filename</parameter> begins with "http://" (not
|
|
|
|
case sensitive), an HTTP 1.0 connection is opened to the
|
2001-07-08 13:37:39 +00:00
|
|
|
specified server, the page is requested using the HTTP GET
|
|
|
|
method, and a file pointer is returned to the beginning
|
|
|
|
of the body of the response. A 'Host:' header is sent with the
|
2000-08-20 04:24:40 +00:00
|
|
|
request in order to handle name-based virtual hosts.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
2001-07-08 13:37:39 +00:00
|
|
|
<simpara>
|
|
|
|
Note that the file pointer allows you to retrieve only the
|
|
|
|
<emphasis>body</emphasis> of the response; you cannot
|
|
|
|
access the HTTP response header using this function.
|
|
|
|
</simpara>
|
2001-06-28 15:46:49 +00:00
|
|
|
<simpara>
|
|
|
|
Versions prior to PHP 4.0.5 do not handle HTTP redirects. Because
|
|
|
|
of this, directories must include trailing slashes.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
1999-12-20 22:26:22 +00:00
|
|
|
If <parameter>filename</parameter> begins with "ftp://" (not case
|
|
|
|
sensitive), an ftp connection to the specified server is opened
|
|
|
|
and a pointer to the requested file is returned. If the server
|
|
|
|
does not support passive mode ftp, this will fail. You can open
|
2000-12-13 22:10:12 +00:00
|
|
|
files for either reading or writing via ftp (but not both
|
1999-12-20 22:26:22 +00:00
|
|
|
simultaneously).
|
2000-01-18 17:33:07 +00:00
|
|
|
</simpara>
|
|
|
|
<simpara>
|
|
|
|
If <parameter>filename</parameter> is one of "php://stdin",
|
|
|
|
"php://stdout", or "php://stderr", the corresponding stdio
|
|
|
|
stream will be opened. (This was introduced in PHP 3.0.13;
|
|
|
|
in earlier versions, a filename such as "/dev/stdin" or
|
|
|
|
"/dev/fd/0" must be used to access the stdio streams.)
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
If <parameter>filename</parameter> begins with anything else, the
|
|
|
|
file will be opened from the filesystem, and a file pointer to
|
1999-12-20 22:26:22 +00:00
|
|
|
the file opened is returned.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
2001-07-07 18:42:46 +00:00
|
|
|
If the open fails, the function returns &false;.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
<parameter>mode</parameter> may be any of the following:
|
|
|
|
<itemizedlist>
|
1999-12-20 22:26:22 +00:00
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2000-11-01 22:41:01 +00:00
|
|
|
'r' - Open for reading only; place the file pointer at the
|
|
|
|
beginning of the file.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2000-11-01 22:41:01 +00:00
|
|
|
'r+' - Open for reading and writing; place the file pointer at
|
|
|
|
the beginning of the file.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2000-11-01 22:41:01 +00:00
|
|
|
'w' - Open for writing only; place the file pointer at the
|
|
|
|
beginning of the file and truncate the file to zero length.
|
|
|
|
If the file does not exist, attempt to create it.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2000-11-01 22:41:01 +00:00
|
|
|
'w+' - Open for reading and writing; place the file pointer at
|
|
|
|
the beginning of the file and truncate the file to zero
|
|
|
|
length. If the file does not exist, attempt to create it.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2000-11-01 22:41:01 +00:00
|
|
|
'a' - Open for writing only; place the file pointer at the end
|
|
|
|
of the file. If the file does not exist, attempt to create
|
|
|
|
it.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>
|
2000-11-01 22:41:01 +00:00
|
|
|
'a+' - Open for reading and writing; place the file pointer at
|
|
|
|
the end of the file. If the file does not exist, attempt to
|
|
|
|
create it.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
|
|
|
</listitem>
|
1999-06-06 18:51:02 +00:00
|
|
|
</itemizedlist>
|
2001-03-06 23:43:03 +00:00
|
|
|
</para>
|
2001-03-07 03:45:30 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
2001-03-06 23:43:03 +00:00
|
|
|
The <parameter>mode</parameter> may contain the letter
|
|
|
|
'b'. This is useful only on systems which differentiate between
|
|
|
|
binary and text files (i.e. Windows. It's useless on Unix).
|
|
|
|
If not needed, this will be ignored.
|
2001-03-07 03:45:30 +00:00
|
|
|
</para>
|
|
|
|
</note>
|
1999-09-07 09:23:47 +00:00
|
|
|
<para>
|
|
|
|
You can use the optional third parameter and set it to "1", if
|
1999-12-20 22:26:22 +00:00
|
|
|
you want to search for the file in the <link
|
|
|
|
linkend="ini.include-path">include_path</link>, too.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
2001-06-23 20:10:52 +00:00
|
|
|
<title><function>fopen</function> example</title>
|
1999-12-20 22:26:22 +00:00
|
|
|
<programlisting role="php">
|
2000-08-15 21:19:54 +00:00
|
|
|
$fp = fopen ("/home/rasmus/file.txt", "r");
|
2000-08-19 04:05:09 +00:00
|
|
|
$fp = fopen ("/home/rasmus/file.gif", "wb");
|
2000-08-15 21:19:54 +00:00
|
|
|
$fp = fopen ("http://www.php.net/", "r");
|
|
|
|
$fp = fopen ("ftp://user:password@example.com/", "w");
|
1999-12-20 22:26:22 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
If you are experiencing problems with reading and writing to
|
1999-12-20 22:26:22 +00:00
|
|
|
files and you're using the server module version of PHP, remember
|
1999-06-06 18:51:02 +00:00
|
|
|
to make sure that the files and directories you're using are
|
1999-12-20 22:26:22 +00:00
|
|
|
accessible to the server process.
|
|
|
|
</simpara>
|
|
|
|
<para>
|
|
|
|
On the Windows platform, be careful to escape any backslashes
|
|
|
|
used in the path to the file, or use forward slashes.
|
|
|
|
<informalexample>
|
|
|
|
<programlisting role="php">
|
2000-08-15 21:19:54 +00:00
|
|
|
$fp = fopen ("c:\\data\\info.txt", "r");
|
1999-12-20 22:26:22 +00:00
|
|
|
</programlisting>
|
|
|
|
</informalexample>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
See also <function>fclose</function>,
|
2000-08-23 07:32:13 +00:00
|
|
|
<function>fsockopen</function>,
|
|
|
|
<function>socket_set_timeout</function>, and
|
|
|
|
<function>popen</function>.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.fpassthru">
|
|
|
|
<refnamediv>
|
1999-12-20 22:26:22 +00:00
|
|
|
<refname>fpassthru</refname>
|
|
|
|
<refpurpose>
|
|
|
|
Output all remaining data on a file pointer
|
|
|
|
</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>fpassthru</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
|
|
|
Reads to EOF on the given file pointer and writes the results to
|
1999-12-20 22:26:22 +00:00
|
|
|
standard output.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
1999-12-20 22:26:22 +00:00
|
|
|
If an error occurs, <function>fpassthru</function> returns
|
2001-07-07 18:42:46 +00:00
|
|
|
&false;.
|
1999-12-20 22:26:22 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
1999-12-20 22:26:22 +00:00
|
|
|
The file pointer must be valid, and must point to a file
|
|
|
|
successfully opened by <function>fopen</function>,
|
|
|
|
<function>popen</function>, or <function>fsockopen</function>.
|
|
|
|
The file is closed when <function>fpassthru</function> is done
|
|
|
|
reading it (leaving <parameter>fp</parameter> useless).
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
1999-12-20 22:26:22 +00:00
|
|
|
If you just want to dump the contents of a file to stdout you may
|
|
|
|
want to use the <function>readfile</function>, which saves you
|
|
|
|
the <function>fopen</function> call.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
1999-12-20 22:26:22 +00:00
|
|
|
See also <function>readfile</function>,
|
|
|
|
<function>fopen</function>, <function>popen</function>, and
|
|
|
|
<function>fsockopen</function>
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.fputs">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fputs</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Writes to a file pointer</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>fputs</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>str</parameter></paramdef>
|
|
|
|
<paramdef>int
|
|
|
|
<parameter>
|
|
|
|
<optional>length</optional>
|
|
|
|
</parameter>
|
|
|
|
</paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-06-23 20:10:52 +00:00
|
|
|
<function>fputs</function> is an alias to
|
1999-12-21 00:24:24 +00:00
|
|
|
<function>fwrite</function>, and is identical in every way. Note
|
|
|
|
that the <parameter>length</parameter> parameter is optional and
|
|
|
|
if not specified the entire string will be written.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.fread">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fread</refname>
|
|
|
|
<refpurpose>Binary-safe file read</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>string <function>fread</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>length</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
2001-06-23 20:10:52 +00:00
|
|
|
<function>fread</function> reads up to
|
1999-06-06 18:51:02 +00:00
|
|
|
<parameter>length</parameter> bytes from the file pointer
|
|
|
|
referenced by <parameter>fp</parameter>. Reading stops when
|
|
|
|
<parameter>length</parameter> bytes have been read or EOF is
|
1999-12-21 00:24:24 +00:00
|
|
|
reached, whichever comes first.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
<informalexample>
|
|
|
|
<programlisting role="php">
|
1999-06-06 18:51:02 +00:00
|
|
|
// get contents of a file into a string
|
|
|
|
$filename = "/usr/local/something.txt";
|
1999-12-21 00:24:24 +00:00
|
|
|
$fd = fopen ($filename, "r");
|
|
|
|
$contents = fread ($fd, filesize ($filename));
|
2001-03-06 23:43:03 +00:00
|
|
|
fclose ($fd);
|
|
|
|
</programlisting>
|
|
|
|
</informalexample>
|
|
|
|
</para>
|
2001-03-07 03:45:30 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
2001-03-06 23:43:03 +00:00
|
|
|
On systems which differentiate between binary and text files
|
|
|
|
(i.e. Windows) the file must be opened with 'b' included in
|
|
|
|
<function>fopen</function> mode parameter.
|
2001-03-07 03:45:30 +00:00
|
|
|
</para>
|
|
|
|
</note>
|
2001-03-06 23:43:03 +00:00
|
|
|
<para>
|
|
|
|
<informalexample>
|
|
|
|
<programlisting role="php">
|
|
|
|
$filename = "c:\\files\\somepic.gif";
|
|
|
|
$fd = fopen ($filename, "rb");
|
|
|
|
$contents = fread ($fd, filesize ($filename));
|
1999-12-21 00:24:24 +00:00
|
|
|
fclose ($fd);
|
1999-06-06 18:51:02 +00:00
|
|
|
</programlisting>
|
1999-12-21 00:24:24 +00:00
|
|
|
</informalexample>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
See also <function>fwrite</function>, <function>fopen</function>,
|
|
|
|
<function>fsockopen</function>, <function>popen</function>,
|
|
|
|
<function>fgets</function>, <function>fgetss</function>,
|
2000-08-15 21:19:54 +00:00
|
|
|
<function>fscanf</function>, <function>file</function>, and
|
|
|
|
<function>fpassthru</function>.
|
1999-12-21 00:24:24 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2000-08-09 10:18:38 +00:00
|
|
|
<refentry id="function.fscanf">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fscanf</refname>
|
|
|
|
<refpurpose>Parses input from a file according to a format</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>mixed <function>fscanf</function></funcdef>
|
|
|
|
<paramdef>int <parameter>handle</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>format</parameter></paramdef>
|
|
|
|
<paramdef>string
|
|
|
|
<parameter><optional>var1</optional></parameter>...
|
|
|
|
</paramdef>
|
|
|
|
</funcprototype>
|
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-08-15 21:19:54 +00:00
|
|
|
The function <function>fscanf</function> is similar to
|
|
|
|
<function>sscanf</function>, but it takes its input from a file
|
|
|
|
associated with <parameter>handle</parameter> and interprets the
|
|
|
|
input according to the specified
|
|
|
|
<parameter>format</parameter>. If only two parameters were passed
|
|
|
|
to this function, the values parsed will be returned as an array.
|
|
|
|
Otherwise, if optional parameters are passed, the function will
|
|
|
|
return the number of assigned values. The optional parameters
|
|
|
|
must be passed by reference.
|
|
|
|
<example>
|
2001-06-23 20:10:52 +00:00
|
|
|
<title><function>fscanf</function> Example</title>
|
2000-08-15 21:19:54 +00:00
|
|
|
<programlisting role="php">
|
|
|
|
$fp = fopen ("users.txt","r");
|
|
|
|
while ($userinfo = fscanf ($fp, "%s\t%s\t%s\n")) {
|
|
|
|
list ($name, $profession, $countrycode) = $userinfo;
|
|
|
|
//... do something with the values
|
2000-08-09 10:18:38 +00:00
|
|
|
}
|
|
|
|
fclose($fp);
|
2000-08-15 21:19:54 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
<example>
|
|
|
|
<title>users.txt</title>
|
|
|
|
<programlisting>
|
|
|
|
javier argonaut pe
|
|
|
|
hiroshi sculptor jp
|
|
|
|
robert slacker us
|
|
|
|
luigi florist it
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>fread</function>, <function>fgets</function>,
|
|
|
|
<function>fgetss</function>, <function>sscanf</function>,
|
|
|
|
<function>printf</function>, and <function>sprintf</function>.
|
2000-08-09 10:18:38 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
1999-06-06 18:51:02 +00:00
|
|
|
<refentry id="function.fseek">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fseek</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Seeks on a file pointer</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>fseek</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>offset</parameter></paramdef>
|
2000-08-15 21:19:54 +00:00
|
|
|
<paramdef>int
|
|
|
|
<parameter><optional>whence</optional></parameter>
|
|
|
|
</paramdef>
|
2000-06-24 07:38:45 +00:00
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2000-04-24 14:36:58 +00:00
|
|
|
Sets the file position indicator for the file referenced by
|
|
|
|
<parameter>fp</parameter>.The new position, measured in bytes
|
|
|
|
from the beginning of the file, is obtained by adding
|
|
|
|
<parameter>offset</parameter> to the position specified by
|
|
|
|
<parameter>whence</parameter>, whose values are defined as
|
|
|
|
follows:
|
|
|
|
<simplelist>
|
|
|
|
<member>SEEK_SET - Set position equal to
|
|
|
|
<parameter>offset</parameter> bytes.</member> <member>SEEK_CUR -
|
|
|
|
Set position to current location plus
|
|
|
|
<parameter>offset</parameter>.</member> <member>SEEK_END - Set
|
|
|
|
position to end-of-file plus
|
|
|
|
<parameter>offset</parameter>.</member>
|
|
|
|
</simplelist>
|
|
|
|
</para>
|
|
|
|
<para>If <parameter>whence is not specified, it is assumed to be
|
|
|
|
SEEK_SET.</parameter>
|
1999-12-20 22:26:22 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
Upon success, returns 0; otherwise, returns -1. Note that seeking
|
1999-12-20 22:26:22 +00:00
|
|
|
past EOF is not considered an error.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-20 22:26:22 +00:00
|
|
|
May not be used on file pointers returned by
|
|
|
|
<function>fopen</function> if they use the "http://" or "ftp://"
|
|
|
|
formats.
|
|
|
|
</para>
|
2000-04-24 14:36:58 +00:00
|
|
|
<note>
|
2000-08-15 21:19:54 +00:00
|
|
|
<para>
|
2000-04-24 14:36:58 +00:00
|
|
|
The <parameter>whence</parameter> argument was added after PHP 4.0 RC1.
|
2000-08-15 21:19:54 +00:00
|
|
|
</para>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
See also <function>ftell</function> and
|
1999-12-20 22:26:22 +00:00
|
|
|
<function>rewind</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2000-07-31 14:41:42 +00:00
|
|
|
<refentry id="function.fstat">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>fstat</refname>
|
|
|
|
<refpurpose>
|
2000-08-15 21:19:54 +00:00
|
|
|
Gets information about a file using an open file pointer
|
2000-07-31 14:41:42 +00:00
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>array <function>fstat</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
</funcprototype>
|
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Gathers the statistics of the file opened by the file
|
|
|
|
pointer fp. This function is similar to the
|
|
|
|
<function>stat</function> function except that it operates
|
|
|
|
on an open file pointer instead of a filename.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Returns an array with the statistics of the file with the
|
|
|
|
following elements:
|
|
|
|
<orderedlist>
|
|
|
|
<listitem><simpara>device</simpara></listitem>
|
|
|
|
<listitem><simpara>inode</simpara></listitem>
|
|
|
|
<listitem><simpara>number of links</simpara></listitem>
|
|
|
|
<listitem><simpara>user id of owner</simpara></listitem>
|
|
|
|
<listitem><simpara>group id owner</simpara></listitem>
|
|
|
|
<listitem><simpara>device type if inode device *</simpara></listitem>
|
|
|
|
<listitem><simpara>size in bytes</simpara></listitem>
|
|
|
|
<listitem><simpara>time of last access</simpara></listitem>
|
|
|
|
<listitem><simpara>time of last modification</simpara></listitem>
|
|
|
|
<listitem><simpara>time of last change</simpara></listitem>
|
|
|
|
<listitem><simpara>blocksize for filesystem I/O *</simpara></listitem>
|
|
|
|
<listitem><simpara>number of blocks allocated</simpara></listitem>
|
|
|
|
</orderedlist>
|
|
|
|
* - only valid on systems supporting the st_blksize type--other
|
|
|
|
systems (i.e. Windows) return -1</para>
|
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
1999-06-06 18:51:02 +00:00
|
|
|
<refentry id="function.ftell">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>ftell</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Tells file pointer read/write position</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>ftell</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Returns the position of the file pointer referenced by fp; i.e.,
|
1999-12-21 00:24:24 +00:00
|
|
|
its offset into the file stream.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
If an error occurs, returns &false;.
|
1999-12-21 00:24:24 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The file pointer must be valid, and must point to a file
|
|
|
|
successfully opened by <function>fopen</function> or
|
1999-12-21 00:24:24 +00:00
|
|
|
<function>popen</function>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>fopen</function>, <function>popen</function>,
|
|
|
|
<function>fseek</function> and <function>rewind</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2000-03-12 18:42:52 +00:00
|
|
|
<refentry id="function.ftruncate">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>ftruncate</refname>
|
|
|
|
<refpurpose>
|
2000-08-15 21:19:54 +00:00
|
|
|
Truncates a file to a given length.
|
2000-03-12 18:42:52 +00:00
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>ftruncate</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>size</parameter></paramdef>
|
|
|
|
</funcprototype>
|
2000-03-12 18:42:52 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Takes the filepointer, fp, and truncates the file to length, size.
|
2001-07-07 18:42:46 +00:00
|
|
|
This function returns &true; on success and &false; on failure.
|
2000-03-12 18:42:52 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2000-04-28 07:30:24 +00:00
|
|
|
<refentry id="function.fwrite">
|
1999-06-06 18:51:02 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>fwrite</refname>
|
|
|
|
<refpurpose>Binary-safe file write</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>fwrite</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>string</parameter></paramdef>
|
|
|
|
<paramdef>int
|
|
|
|
<parameter>
|
|
|
|
<optional>length</optional>
|
|
|
|
</parameter>
|
|
|
|
</paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
|
|
|
<function>fwrite</function> writes the contents of
|
|
|
|
<parameter>string</parameter> to the file stream pointed to by
|
|
|
|
<parameter>fp</parameter>. If the <parameter>length</parameter>
|
|
|
|
argument is given, writing will stop after
|
|
|
|
<parameter>length</parameter> bytes have been written or the end
|
|
|
|
of <parameter>string</parameter> is reached, whichever comes
|
1999-12-21 00:24:24 +00:00
|
|
|
first.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
Note that if the <parameter>length</parameter> argument is given,
|
1999-12-21 00:24:24 +00:00
|
|
|
then the <link
|
|
|
|
linkend="ini.magic-quotes-runtime">magic_quotes_runtime</link>
|
1999-06-06 18:51:02 +00:00
|
|
|
configuration option will be ignored and no slashes will be
|
1999-12-21 00:24:24 +00:00
|
|
|
stripped from <parameter>string</parameter>.
|
|
|
|
</simpara>
|
2001-03-17 19:25:37 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
On systems which differentiate between binary and text files
|
|
|
|
(i.e. Windows) the file must be opened with 'b' included in
|
|
|
|
<function>fopen</function> mode parameter.
|
|
|
|
</para>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
<simpara>
|
|
|
|
See also <function>fread</function>, <function>fopen</function>,
|
|
|
|
<function>fsockopen</function>, <function>popen</function>, and
|
1999-12-21 00:24:24 +00:00
|
|
|
<function>fputs</function>.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.set-file-buffer">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>set_file_buffer</refname>
|
1999-12-21 00:24:24 +00:00
|
|
|
<refpurpose>
|
|
|
|
Sets file buffering on the given file pointer
|
|
|
|
</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>set_file_buffer</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>buffer</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<simpara>
|
2000-08-31 14:16:36 +00:00
|
|
|
Output using <function>fwrite</function> is normally buffered at
|
|
|
|
8K. This means that if there are two processess wanting to write
|
|
|
|
to the same output stream (a file), each is paused after 8K of
|
|
|
|
data to allow the other to write. <function>set_file_buffer</function>
|
|
|
|
sets the buffering for write operations on the given filepointer
|
|
|
|
<parameter>fp</parameter> to <parameter>buffer</parameter> bytes.
|
|
|
|
If <parameter>buffer</parameter> is 0 then write operations are
|
|
|
|
unbuffered. This ensures that all writes with
|
|
|
|
<function>fwrite</function> are completed before other processes
|
|
|
|
are allowed to write to that output stream.
|
1999-12-21 00:24:24 +00:00
|
|
|
</simpara>
|
|
|
|
<simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
The function returns 0 on success, or EOF if the request cannot
|
1999-12-21 00:24:24 +00:00
|
|
|
be honored.
|
|
|
|
</simpara>
|
2000-08-31 14:16:36 +00:00
|
|
|
<para>
|
|
|
|
The following example demonstrates how to use
|
|
|
|
<function>set_file_buffer</function> to create an unbuffered stream.
|
|
|
|
<example>
|
|
|
|
<title><function>set_file_buffer</function> example</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
$fp=fopen($file, "w");
|
|
|
|
if($fp){
|
|
|
|
set_file_buffer($fp, 0);
|
|
|
|
fputs($fp, $output);
|
|
|
|
fclose($fp);
|
|
|
|
}
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
|
1999-12-21 00:24:24 +00:00
|
|
|
<simpara>
|
2000-08-31 14:16:36 +00:00
|
|
|
See also <function>fopen</function>, <function>fwrite</function>.
|
1999-12-21 00:24:24 +00:00
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.is-dir">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>is_dir</refname>
|
1999-12-21 00:24:24 +00:00
|
|
|
<refpurpose>Tells whether the filename is a directory</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>bool <function>is_dir</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; if the filename exists and is a directory.
|
1999-12-21 00:24:24 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-21 00:24:24 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
2001-03-26 23:39:25 +00:00
|
|
|
<simpara>
|
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
See also <function>is_file</function> and
|
|
|
|
<function>is_link</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.is-executable">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>is_executable</refname>
|
1999-12-21 00:24:24 +00:00
|
|
|
<refpurpose>Tells whether the filename is executable</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>bool <function>is_executable</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; if the filename exists and is executable.
|
1999-12-21 00:24:24 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-21 00:24:24 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
2001-03-26 23:39:25 +00:00
|
|
|
<simpara>
|
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
See also <function>is_file</function> and
|
|
|
|
<function>is_link</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.is-file">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>is_file</refname>
|
1999-12-21 00:24:24 +00:00
|
|
|
<refpurpose>
|
|
|
|
Tells whether the filename is a regular file
|
|
|
|
</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>bool <function>is_file</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; if the filename exists and is a regular file.
|
1999-12-21 00:24:24 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-21 00:24:24 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
See also <function>is_dir</function> and
|
|
|
|
<function>is_link</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.is-link">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>is_link</refname>
|
1999-12-21 00:24:24 +00:00
|
|
|
<refpurpose>
|
|
|
|
Tells whether the filename is a symbolic link
|
|
|
|
</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>bool <function>is_link</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; if the filename exists and is a symbolic link.
|
1999-12-21 00:24:24 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-21 00:24:24 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
See also <function>is_dir</function> and
|
|
|
|
<function>is_file</function>.
|
|
|
|
</para>
|
2001-03-26 23:39:25 +00:00
|
|
|
<simpara>
|
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
|
|
|
</simpara>
|
2000-02-25 00:02:34 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
|
|
|
This function does not work on Windows systems
|
|
|
|
</simpara>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.is-readable">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>is_readable</refname>
|
1999-12-21 00:24:24 +00:00
|
|
|
<refpurpose>
|
|
|
|
Tells whether the filename is readable
|
|
|
|
</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>bool <function>is_readable</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; if the filename exists and is readable.
|
1999-12-21 00:24:24 +00:00
|
|
|
</para>
|
2000-04-28 07:30:24 +00:00
|
|
|
<para>
|
1999-06-06 18:51:02 +00:00
|
|
|
Keep in mind that PHP may be accessing the file as the user
|
|
|
|
id that the web server runs as (often 'nobody'). Safe mode
|
1999-12-21 00:24:24 +00:00
|
|
|
limitations are not taken into account.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-21 00:24:24 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
2001-03-26 23:39:25 +00:00
|
|
|
<simpara>
|
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2001-01-03 19:17:46 +00:00
|
|
|
See also <function>is_writable</function>.
|
1999-12-21 00:24:24 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2001-01-03 19:17:46 +00:00
|
|
|
<refentry id="function.is-writable">
|
1999-06-06 18:51:02 +00:00
|
|
|
<refnamediv>
|
2001-01-03 19:17:46 +00:00
|
|
|
<refname>is_writable</refname>
|
|
|
|
<refpurpose>Tells whether the filename is writable</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
2001-01-03 19:17:46 +00:00
|
|
|
<funcdef>bool <function>is_writable</function></funcdef>
|
2000-06-24 07:38:45 +00:00
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; if the filename exists and is writable. The
|
1999-12-21 00:24:24 +00:00
|
|
|
filename argument may be a directory name allowing you to check
|
|
|
|
if a directory is writeable.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
Keep in mind that PHP may be accessing the file as the user id
|
|
|
|
that the web server runs as (often 'nobody'). Safe mode
|
|
|
|
limitations are not taken into account.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-21 00:24:24 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
2001-03-26 23:39:25 +00:00
|
|
|
<simpara>
|
|
|
|
This function will not work on <link
|
|
|
|
linkend="features.remote-files">remote files</link>; the file to
|
|
|
|
be examined must be accessible via the server's filesystem.
|
|
|
|
</simpara>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
See also <function>is_readable</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2001-03-07 23:15:13 +00:00
|
|
|
<refentry id="function.is-writeable">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>is_writeable</refname>
|
|
|
|
<refpurpose>Tells whether the filename is writable</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>bool <function>is_writeable</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
This is an alias for <function>is_writable</function>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2000-09-10 11:14:16 +00:00
|
|
|
<refentry id="function.is-uploaded-file">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>is_uploaded_file</refname>
|
|
|
|
<refpurpose>Tells whether the file was uploaded via HTTP POST.</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>bool <function>is_uploaded_file</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
This function is available only in versions of PHP 3 after PHP
|
|
|
|
3.0.16, and in versions of PHP 4 after 4.0.2.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; if the file named by <varname>filename</varname> was
|
2000-09-10 11:14:16 +00:00
|
|
|
uploaded via HTTP POST. This is useful to help ensure that a
|
|
|
|
malicious user hasn't tried to trick the script into working on
|
|
|
|
files upon which it should not be working--for instance,
|
|
|
|
<filename>/etc/passwd</filename>.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
This sort of check is especially important if there is any chance
|
|
|
|
that anything done with uploaded files could reveal their
|
|
|
|
contents to the user, or even to other users on the same
|
|
|
|
system.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
See also <function>move_uploaded_file</function>, and the section
|
|
|
|
<link linkend="features.file-upload">Handling file uploads</link>
|
|
|
|
for a simple usage example.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
1999-06-06 18:51:02 +00:00
|
|
|
<refentry id="function.link">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>link</refname>
|
|
|
|
<refpurpose>Create a hard link</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>link</function></funcdef>
|
|
|
|
<paramdef>string <parameter>target</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>link</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-06-23 20:10:52 +00:00
|
|
|
<function>link</function> creates a hard link.</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
See also the <function>symlink</function> to create soft links,
|
|
|
|
and <function>readlink</function> along with
|
|
|
|
<function>linkinfo</function>.
|
|
|
|
</para>
|
2000-02-25 00:02:34 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
|
|
|
This function does not work on Windows systems
|
|
|
|
</simpara>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.linkinfo">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>linkinfo</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Gets information about a link</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>linkinfo</function></funcdef>
|
|
|
|
<paramdef>string <parameter>path</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-06-23 20:10:52 +00:00
|
|
|
<function>linkinfo</function> returns the st_dev field of the
|
1999-12-21 00:24:24 +00:00
|
|
|
UNIX C stat structure returned by the lstat system call. This
|
|
|
|
function is used to verify if a link (pointed to by
|
|
|
|
<parameter>path</parameter>) really exists (using the same method
|
2001-07-07 18:42:46 +00:00
|
|
|
as the S_ISLNK macro defined in stat.h). Returns 0 or &false; in
|
1999-12-21 00:24:24 +00:00
|
|
|
case of error.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
See also <function>symlink</function>, <function>link</function>,
|
|
|
|
and <function>readlink</function>.
|
|
|
|
</para>
|
2000-02-25 00:02:34 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
|
|
|
This function does not work on Windows systems
|
|
|
|
</simpara>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.mkdir">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>mkdir</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Makes directory</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>mkdir</function></funcdef>
|
|
|
|
<paramdef>string <parameter>pathname</parameter></paramdef>
|
|
|
|
<paramdef>int <parameter>mode</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
Attempts to create the directory specified by pathname.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
Note that you probably want to specify the mode as an
|
|
|
|
octal number, which means it should have a leading zero.
|
2001-07-08 03:54:12 +00:00
|
|
|
The mode is also modified by the current umask, which you
|
|
|
|
can change using <function>umask</function>.
|
1999-12-21 00:24:24 +00:00
|
|
|
<informalexample>
|
|
|
|
<programlisting role="php">
|
|
|
|
mkdir ("/path/to/my/dir", 0700);
|
|
|
|
</programlisting>
|
|
|
|
</informalexample>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; on success and &false; on failure.
|
1999-12-21 00:24:24 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
See also <function>rmdir</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2000-09-10 11:14:16 +00:00
|
|
|
<refentry id="function.move-uploaded-file">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>move_uploaded_file</refname>
|
|
|
|
<refpurpose>Moves an uploaded file to a new location.</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>bool <function>move_uploaded_file</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>destination</parameter></paramdef>
|
|
|
|
</funcprototype>
|
|
|
|
</funcsynopsis>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
This function is available only in versions of PHP 3 after PHP
|
|
|
|
3.0.16, and in versions of PHP 4 after 4.0.2.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
This function checks to ensure that the file designated by
|
|
|
|
<parameter>filename</parameter> is a valid upload file (meaning
|
|
|
|
that it was uploaded via PHP's HTTP POST upload mechanism). If
|
|
|
|
the file is valid, it will be moved to the filename given by
|
|
|
|
<parameter>destination</parameter>.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
If <parameter>filename</parameter> is not a valid upload file,
|
|
|
|
then no action will occur, and
|
|
|
|
<function>move_uploaded_file</function> will return
|
2001-07-07 18:42:46 +00:00
|
|
|
&false;.
|
2000-09-10 11:14:16 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
If <parameter>filename</parameter> is a valid upload file, but
|
|
|
|
cannot be moved for some reason, no action will occur, and
|
|
|
|
<function>move_uploaded_file</function> will return
|
2001-07-07 18:42:46 +00:00
|
|
|
&false;. Additionally, a warning will be issued.
|
2000-09-10 11:14:16 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
This sort of check is especially important if there is any chance
|
|
|
|
that anything done with uploaded files could reveal their
|
|
|
|
contents to the user, or even to other users on the same
|
|
|
|
system.
|
|
|
|
</para>
|
|
|
|
|
2001-07-31 22:28:30 +00:00
|
|
|
¬e.sm.uidcheck;
|
|
|
|
|
2000-09-10 11:14:16 +00:00
|
|
|
<para>
|
|
|
|
See also <function>is_uploaded_file</function>, and the section
|
|
|
|
<link linkend="features.file-upload">Handling file uploads</link>
|
|
|
|
for a simple usage example.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2001-04-02 16:43:28 +00:00
|
|
|
|
|
|
|
<refentry id="function.pathinfo">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>pathinfo</refname>
|
|
|
|
<refpurpose>Returns information about a file path</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>array <function>pathinfo</function></funcdef>
|
|
|
|
<paramdef>string <parameter>path</parameter></paramdef>
|
|
|
|
</funcprototype>
|
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
<function>pathinfo</function> returns an associative array
|
|
|
|
containing information about <parameter>path</parameter>. The
|
|
|
|
following array elements are returned:
|
|
|
|
<parameter>dirname</parameter>, <parameter>basename</parameter>
|
|
|
|
and <parameter>extension</parameter>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>pathinfo</function> Example</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$path_parts = pathinfo("/www/htdocs/index.html");
|
|
|
|
|
|
|
|
echo $path_parts["dirname"] . "\n";
|
|
|
|
echo $path_parts["basename"] . "\n";
|
|
|
|
echo $path_parts["extension"] . "\n";
|
|
|
|
|
|
|
|
?>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Would produce:
|
|
|
|
<informalexample>
|
|
|
|
<programlisting>
|
|
|
|
/www/htdocs
|
|
|
|
index.html
|
|
|
|
html
|
|
|
|
</programlisting>
|
|
|
|
</informalexample>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>dirname</function>,
|
|
|
|
<function>basename</function> and <function>realpath</function>.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
|
1999-06-06 18:51:02 +00:00
|
|
|
<refentry id="function.pclose">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>pclose</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Closes process file pointer</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>pclose</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
1999-12-21 00:24:24 +00:00
|
|
|
<para>
|
|
|
|
Closes a file pointer to a pipe opened by
|
|
|
|
<function>popen</function>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
The file pointer must be valid, and must have been returned by a
|
|
|
|
successful call to <function>popen</function>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Returns the termination status of the process that was
|
|
|
|
run.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>popen</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.popen">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>popen</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Opens process file pointer</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>popen</function></funcdef>
|
|
|
|
<paramdef>string <parameter>command</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>mode</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
1999-12-21 00:24:24 +00:00
|
|
|
<para>
|
|
|
|
Opens a pipe to a process executed by forking the command given
|
|
|
|
by command.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Returns a file pointer identical to that returned by
|
|
|
|
<function>fopen</function>, except that it is unidirectional (may
|
|
|
|
only be used for reading or writing) and must be closed with
|
|
|
|
<function>pclose</function>. This pointer may be used with
|
|
|
|
<function>fgets</function>, <function>fgetss</function>, and
|
|
|
|
<function>fputs</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
If an error occurs, returns &false;.
|
1999-12-21 00:24:24 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
<informalexample>
|
1999-12-21 00:24:24 +00:00
|
|
|
<programlisting role="php">
|
|
|
|
$fp = popen ("/bin/ls", "r");
|
|
|
|
</programlisting>
|
|
|
|
</informalexample>
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
See also <function>pclose</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.readfile">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>readfile</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Outputs a file</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>readfile</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
<paramdef>int
|
|
|
|
<parameter>
|
|
|
|
<optional>use_include_path</optional>
|
|
|
|
</parameter>
|
|
|
|
</paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
Reads a file and writes it to standard output.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
Returns the number of bytes read from the file. If an error
|
2001-07-07 18:42:46 +00:00
|
|
|
occurs, &false; is returned and unless the function was called as
|
1999-12-21 00:24:24 +00:00
|
|
|
@readfile, an error message is printed.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
If <parameter>filename</parameter> begins with "http://"
|
|
|
|
(not case sensitive), an HTTP 1.0 connection is opened to the
|
|
|
|
specified server and the text of the response is written to
|
1999-12-21 00:24:24 +00:00
|
|
|
standard output.
|
|
|
|
</para>
|
2001-06-28 15:46:49 +00:00
|
|
|
<para>
|
|
|
|
Versions prior to PHP 4.0.5 do not handle HTTP redirects. Because
|
|
|
|
of this, directories must include trailing slashes.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
If <parameter>filename</parameter> begins with "ftp://"
|
|
|
|
(not case sensitive), an ftp connection to the specified server is
|
|
|
|
opened and the requested file is written to standard output. If the server
|
1999-12-21 00:24:24 +00:00
|
|
|
does not support passive mode ftp, this will fail.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
If <parameter>filename</parameter> begins with neither
|
|
|
|
of these strings, the file will be opened from the filesystem and
|
1999-12-21 00:24:24 +00:00
|
|
|
its contents written to standard output.
|
|
|
|
</para>
|
1999-09-07 09:23:47 +00:00
|
|
|
<para>
|
|
|
|
You can use the optional second parameter and set it to "1", if
|
1999-12-21 00:24:24 +00:00
|
|
|
you want to search for the file in the <link
|
|
|
|
linkend="ini.include-path">include_path</link>, too.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
See also <function>fpassthru</function>,
|
|
|
|
<function>file</function>, <function>fopen</function>,
|
|
|
|
<function>include</function>, <function>require</function>, and
|
|
|
|
<function>virtual</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.readlink">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>readlink</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Returns the target of a symbolic link</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>string <function>readlink</function></funcdef>
|
|
|
|
<paramdef>string <parameter>path</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-06-23 20:10:52 +00:00
|
|
|
<function>readlink</function> does the same as the readlink C
|
1999-12-21 00:24:24 +00:00
|
|
|
function and returns the contents of the symbolic link path or 0
|
|
|
|
in case of error.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
See also <function>symlink</function>,
|
|
|
|
<function>readlink</function> and
|
|
|
|
<function>linkinfo</function>.
|
|
|
|
</para>
|
2000-02-25 00:02:34 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
|
|
|
This function does not work on Windows systems
|
|
|
|
</simpara>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.rename">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>rename</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Renames a file</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>rename</function></funcdef>
|
|
|
|
<paramdef>string <parameter>oldname</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>newname</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
1999-12-21 00:24:24 +00:00
|
|
|
<para>
|
|
|
|
Attempts to rename <parameter>oldname</parameter> to
|
|
|
|
<parameter>newname</parameter>.
|
|
|
|
</para>
|
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; on success and &false; on failure.
|
1999-12-21 00:24:24 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.rewind">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>rewind</refname>
|
1999-12-21 00:24:24 +00:00
|
|
|
<refpurpose>Rewind the position of a file pointer</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>rewind</function></funcdef>
|
|
|
|
<paramdef>int <parameter>fp</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
1999-12-21 00:24:24 +00:00
|
|
|
<para>
|
|
|
|
Sets the file position indicator for fp to the beginning of the
|
|
|
|
file stream.</para> <para> If an error occurs, returns 0.</para>
|
|
|
|
<para> The file pointer must be valid, and must point to a file
|
|
|
|
successfully opened by <function>fopen</function>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>fseek</function> and
|
|
|
|
<function>ftell</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
|
|
|
|
<refentry id="function.rmdir">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>rmdir</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Removes directory</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>rmdir</function></funcdef>
|
|
|
|
<paramdef>string <parameter>dirname</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
1999-12-21 00:24:24 +00:00
|
|
|
<para>
|
|
|
|
Attempts to remove the directory named by pathname. The directory
|
|
|
|
must be empty, and the relevant permissions must permit.
|
|
|
|
this.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
If an error occurs, returns 0.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>mkdir</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.stat">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>stat</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Gives information about a file</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>array <function>stat</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-05-14 12:37:47 +00:00
|
|
|
Gathers the statistics of the file named by filename.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
Returns an array with the statistics of the file with the
|
|
|
|
following elements:
|
|
|
|
<orderedlist>
|
|
|
|
<listitem><simpara>device</simpara></listitem>
|
|
|
|
<listitem><simpara>inode</simpara></listitem>
|
|
|
|
<listitem><simpara>inode protection mode</simpara></listitem>
|
|
|
|
<listitem><simpara>number of links</simpara></listitem>
|
|
|
|
<listitem><simpara>user id of owner</simpara></listitem>
|
|
|
|
<listitem><simpara>group id owner</simpara></listitem>
|
|
|
|
<listitem><simpara>device type if inode device *</simpara></listitem>
|
|
|
|
<listitem><simpara>size in bytes</simpara></listitem>
|
|
|
|
<listitem><simpara>time of last access</simpara></listitem>
|
|
|
|
<listitem><simpara>time of last modification</simpara></listitem>
|
|
|
|
<listitem><simpara>time of last change</simpara></listitem>
|
|
|
|
<listitem><simpara>blocksize for filesystem I/O *</simpara></listitem>
|
|
|
|
<listitem><simpara>number of blocks allocated</simpara></listitem>
|
|
|
|
</orderedlist>
|
|
|
|
* - only valid on systems supporting the st_blksize type--other
|
2001-05-14 12:37:47 +00:00
|
|
|
systems (i.e. Windows) return -1.
|
|
|
|
</para>
|
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &false; in case of error.
|
2001-05-14 12:37:47 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<function>stat</function> doesn't handle URL as does <function>fopen</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-21 00:24:24 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.lstat">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>lstat</refname>
|
1999-12-21 00:24:24 +00:00
|
|
|
<refpurpose>
|
2000-08-15 21:19:54 +00:00
|
|
|
Gives information about a file or symbolic link
|
1999-12-21 00:24:24 +00:00
|
|
|
</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>array <function>lstat</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
Gathers the statistics of the file or symbolic link named by
|
|
|
|
filename. This function is identical to the
|
|
|
|
<function>stat</function> function except that if the
|
|
|
|
<parameter>filename</parameter> parameter is a symbolic link, the
|
|
|
|
status of the symbolic link is returned, not the status of the
|
|
|
|
file pointed to by the symbolic link.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
Returns an array with the statistics of the file with the
|
|
|
|
following elements:
|
|
|
|
<orderedlist>
|
|
|
|
<listitem><simpara>device</simpara></listitem>
|
|
|
|
<listitem><simpara>inode</simpara></listitem>
|
2000-09-14 23:25:43 +00:00
|
|
|
<listitem><simpara>inode protection mode</simpara></listitem>
|
1999-06-06 18:51:02 +00:00
|
|
|
<listitem><simpara>number of links</simpara></listitem>
|
|
|
|
<listitem><simpara>user id of owner</simpara></listitem>
|
|
|
|
<listitem><simpara>group id owner</simpara></listitem>
|
|
|
|
<listitem><simpara>device type if inode device *</simpara></listitem>
|
|
|
|
<listitem><simpara>size in bytes</simpara></listitem>
|
|
|
|
<listitem><simpara>time of last access</simpara></listitem>
|
|
|
|
<listitem><simpara>time of last modification</simpara></listitem>
|
|
|
|
<listitem><simpara>time of last change</simpara></listitem>
|
|
|
|
<listitem><simpara>blocksize for filesystem I/O *</simpara></listitem>
|
|
|
|
<listitem><simpara>number of blocks allocated</simpara></listitem>
|
|
|
|
</orderedlist>
|
|
|
|
* - only valid on systems supporting the st_blksize type--other
|
1999-10-20 22:41:42 +00:00
|
|
|
systems (i.e. Windows) return -1</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
The results of this function are cached. See
|
1999-12-21 00:24:24 +00:00
|
|
|
<function>clearstatcache</function> for more details.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2000-07-11 20:06:21 +00:00
|
|
|
<refentry id="function.realpath">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>realpath</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Returns canonicalized absolute pathname</refpurpose>
|
2000-07-11 20:06:21 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>string <function>realpath</function></funcdef>
|
|
|
|
<paramdef>string <parameter>path</parameter></paramdef>
|
|
|
|
</funcprototype>
|
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
<function>realpath</function> expands all symbolic links and
|
|
|
|
resolves references to '/./', '/../' and extra '/' characters in
|
|
|
|
the input <parameter>path</parameter> and return the canonicalized
|
|
|
|
absolute pathname. The resulting path will have no symbolic link,
|
|
|
|
'/./' or '/../' components.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>realpath</function> example</title>
|
|
|
|
<programlisting role="php">
|
2000-08-15 21:19:54 +00:00
|
|
|
$real_path = realpath ("../../index.php");
|
2000-07-11 20:06:21 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
1999-06-06 18:51:02 +00:00
|
|
|
<refentry id="function.symlink">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>symlink</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Creates a symbolic link</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>symlink</function></funcdef>
|
|
|
|
<paramdef>string <parameter>target</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>link</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
<function>symlink</function> creates a symbolic link
|
|
|
|
from the existing <parameter>target</parameter> with
|
1999-12-21 00:24:24 +00:00
|
|
|
the specified name <parameter>link</parameter>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
|
|
|
See also <function>link</function> to create hard links,
|
|
|
|
and <function>readlink</function> along with
|
1999-12-21 00:24:24 +00:00
|
|
|
<function>linkinfo</function>.
|
|
|
|
</para>
|
2000-02-25 00:02:34 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
2000-08-15 21:19:54 +00:00
|
|
|
This function does not work on Windows systems.
|
2000-02-25 00:02:34 +00:00
|
|
|
</simpara>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.tempnam">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>tempnam</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Creates unique file name</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>string <function>tempnam</function></funcdef>
|
|
|
|
<paramdef>string <parameter>dir</parameter></paramdef>
|
|
|
|
<paramdef>string <parameter>prefix</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Creates a unique temporary filename in the specified directory.
|
1999-12-21 00:24:24 +00:00
|
|
|
If the directory does not exist, <function>tempnam</function> may
|
|
|
|
generate a filename in the system's temporary directory.
|
|
|
|
</para>
|
1999-07-07 06:43:57 +00:00
|
|
|
<para>
|
2001-06-27 06:53:54 +00:00
|
|
|
Prior to PHP 4.0.6, the behaviour of the
|
|
|
|
<function>tempnam</function> function was system dependent. On
|
|
|
|
Windows the TMP environment variable will override the
|
|
|
|
<parameter>dir</parameter> parameter, on Linux the TMPDIR
|
|
|
|
environment variable has precedence, while SVR4 will always use
|
|
|
|
your <parameter>dir</parameter> parameter if the directory it
|
|
|
|
points to exists. Consult your system documentation on the
|
1999-12-21 00:24:24 +00:00
|
|
|
tempnam(3) function if in doubt.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns the new temporary filename, or the &null; string on
|
1999-06-06 18:51:02 +00:00
|
|
|
failure.
|
1999-12-21 00:24:24 +00:00
|
|
|
<example>
|
2001-06-23 20:10:52 +00:00
|
|
|
<title><function>tempnam</function> example</title>
|
1999-12-21 00:24:24 +00:00
|
|
|
<programlisting role="php">
|
|
|
|
$tmpfname = tempnam ("/tmp", "FOO");
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
2000-11-05 18:21:52 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
2000-11-26 21:52:37 +00:00
|
|
|
This function's behavior changed in 4.0.3. The temporary file is also
|
2000-11-05 18:56:52 +00:00
|
|
|
created to avoid a race condition where the file might appear in the
|
2000-11-05 18:32:11 +00:00
|
|
|
filesystem between the time the string was generated and before the
|
|
|
|
the script gets around to creating the file.
|
2000-11-05 18:21:52 +00:00
|
|
|
</simpara>
|
|
|
|
</note>
|
2000-11-01 21:55:46 +00:00
|
|
|
<para>
|
|
|
|
See also <function>tmpfile</function>.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
2000-08-20 19:48:11 +00:00
|
|
|
<refentry id="function.tmpfile">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>tmpfile</refname>
|
|
|
|
<refpurpose>Creates a temporary file</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>tmpfile</function></funcdef>
|
2001-05-16 18:33:21 +00:00
|
|
|
<void/>
|
2000-08-20 19:48:11 +00:00
|
|
|
</funcprototype>
|
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Creates a temporary file with an unique name in write mode,
|
2000-08-27 01:44:41 +00:00
|
|
|
returning a file handle similar to the one returned by
|
|
|
|
<function>fopen</function>.
|
|
|
|
The file is automatically removed when closed (using
|
|
|
|
<function>fclose</function>), or when the script ends.
|
2000-08-20 19:48:11 +00:00
|
|
|
</para>
|
2000-08-27 01:44:41 +00:00
|
|
|
<para>
|
|
|
|
For details, consult your system documentation on the
|
|
|
|
<literal>tmpfile(3)</literal> function, as well as the
|
|
|
|
<filename>stdio.h</filename> header file.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>tempnam</function>.
|
2000-08-20 19:48:11 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
|
1999-06-06 18:51:02 +00:00
|
|
|
<refentry id="function.touch">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>touch</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Sets modification time of file</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>touch</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
<paramdef>int
|
2000-11-01 21:55:46 +00:00
|
|
|
<parameter>
|
|
|
|
<optional>time</optional>
|
|
|
|
</parameter>
|
2000-06-24 07:38:45 +00:00
|
|
|
</paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
|
|
|
Attempts to set the modification time of the file named by
|
|
|
|
filename to the value given by time. If the option time is not
|
1999-12-21 00:24:24 +00:00
|
|
|
given, uses the present time.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
If the file does not exist, it is created.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns &true; on success and &false; otherwise.
|
2000-02-19 01:49:29 +00:00
|
|
|
<example>
|
2001-06-23 20:10:52 +00:00
|
|
|
<title><function>touch</function> example</title>
|
2000-02-19 01:49:29 +00:00
|
|
|
<programlisting role="php">
|
2000-08-15 21:19:54 +00:00
|
|
|
if (touch ($FileName)) {
|
|
|
|
print "$FileName modification time has been
|
|
|
|
changed to todays date and time";
|
2000-02-19 01:49:29 +00:00
|
|
|
} else {
|
2000-08-15 21:19:54 +00:00
|
|
|
print "Sorry Could Not change modification time of $FileName";
|
2000-02-19 01:49:29 +00:00
|
|
|
}
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
1999-12-21 00:24:24 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.umask">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>umask</refname>
|
1999-12-21 00:24:24 +00:00
|
|
|
<refpurpose>Changes the current umask</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>umask</function></funcdef>
|
|
|
|
<paramdef>int <parameter>mask</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
2001-06-23 20:10:52 +00:00
|
|
|
<function>umask</function> sets PHP's umask to mask & 0777 and
|
1999-12-21 00:24:24 +00:00
|
|
|
returns the old umask. When PHP is being used as a server module,
|
|
|
|
the umask is restored when each request is finished.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2001-06-23 20:10:52 +00:00
|
|
|
<function>umask</function> without arguments simply returns the
|
1999-12-21 00:24:24 +00:00
|
|
|
current umask.
|
|
|
|
</para>
|
2000-10-01 23:12:15 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
|
|
|
This function may not work on Windows systems.
|
|
|
|
</simpara>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<refentry id="function.unlink">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>unlink</refname>
|
2000-08-15 21:19:54 +00:00
|
|
|
<refpurpose>Deletes a file</refpurpose>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<funcsynopsis>
|
2000-06-24 07:38:45 +00:00
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>unlink</function></funcdef>
|
|
|
|
<paramdef>string <parameter>filename</parameter></paramdef>
|
|
|
|
</funcprototype>
|
1999-06-06 18:51:02 +00:00
|
|
|
</funcsynopsis>
|
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
Deletes <parameter>filename</parameter>. Similar to the Unix C
|
|
|
|
unlink() function.
|
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
2001-07-07 18:42:46 +00:00
|
|
|
Returns 0 or &false; on an error.
|
1999-12-21 00:24:24 +00:00
|
|
|
</para>
|
1999-06-06 18:51:02 +00:00
|
|
|
<para>
|
1999-12-21 00:24:24 +00:00
|
|
|
See also <function>rmdir</function> for removing directories.
|
|
|
|
</para>
|
2000-02-25 00:02:34 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
2000-08-15 21:19:54 +00:00
|
|
|
This function may not work on Windows systems.
|
2000-02-25 00:02:34 +00:00
|
|
|
</simpara>
|
|
|
|
</note>
|
1999-06-06 18:51:02 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
</reference>
|
|
|
|
|
|
|
|
<!-- 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
|
|
|
|
sgml-parent-document:nil
|
1999-12-20 22:26:22 +00:00
|
|
|
sgml-default-dtd-file:"../../manual.ced"
|
1999-06-06 18:51:02 +00:00
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
2001-09-21 22:47:49 +00:00
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
1999-06-06 18:51:02 +00:00
|
|
|
-->
|