mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-20 02:48:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@302986 c90b9560-bf6c-de11-be94-00142212c4b1
272 lines
6.2 KiB
XML
272 lines
6.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.stat">
|
|
<refnamediv>
|
|
<refname>stat</refname>
|
|
<refpurpose>Gives information about a file</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>stat</methodname>
|
|
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Gathers the statistics of the file named by
|
|
<parameter>filename</parameter>. If <parameter>filename</parameter> is a
|
|
symbolic link, statistics are from the file itself, not the symlink.
|
|
</para>
|
|
<para>
|
|
<function>lstat</function> is identical to <function>stat</function>
|
|
except it would instead be based off the symlinks status.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>filename</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Path to the file.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
<table>
|
|
<title><function>stat</function> and <function>fstat</function> result
|
|
format</title>
|
|
<tgroup cols="3">
|
|
<thead>
|
|
<row>
|
|
<entry>Numeric</entry>
|
|
<entry>Associative (since PHP 4.0.6)</entry>
|
|
<entry>Description</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>0</entry>
|
|
<entry>dev</entry>
|
|
<entry>device number</entry>
|
|
</row>
|
|
<row>
|
|
<entry>1</entry>
|
|
<entry>ino</entry>
|
|
<entry>inode number *</entry>
|
|
</row>
|
|
<row>
|
|
<entry>2</entry>
|
|
<entry>mode</entry>
|
|
<entry>inode protection mode</entry>
|
|
</row>
|
|
<row>
|
|
<entry>3</entry>
|
|
<entry>nlink</entry>
|
|
<entry>number of links</entry>
|
|
</row>
|
|
<row>
|
|
<entry>4</entry>
|
|
<entry>uid</entry>
|
|
<entry>userid of owner *</entry>
|
|
</row>
|
|
<row>
|
|
<entry>5</entry>
|
|
<entry>gid</entry>
|
|
<entry>groupid of owner *</entry>
|
|
</row>
|
|
<row>
|
|
<entry>6</entry>
|
|
<entry>rdev</entry>
|
|
<entry>device type, if inode device</entry>
|
|
</row>
|
|
<row>
|
|
<entry>7</entry>
|
|
<entry>size</entry>
|
|
<entry>size in bytes</entry>
|
|
</row>
|
|
<row>
|
|
<entry>8</entry>
|
|
<entry>atime</entry>
|
|
<entry>time of last access (Unix timestamp)</entry>
|
|
</row>
|
|
<row>
|
|
<entry>9</entry>
|
|
<entry>mtime</entry>
|
|
<entry>time of last modification (Unix timestamp)</entry>
|
|
</row>
|
|
<row>
|
|
<entry>10</entry>
|
|
<entry>ctime</entry>
|
|
<entry>time of last inode change (Unix timestamp)</entry>
|
|
</row>
|
|
<row>
|
|
<entry>11</entry>
|
|
<entry>blksize</entry>
|
|
<entry>blocksize of filesystem IO **</entry>
|
|
</row>
|
|
<row>
|
|
<entry>12</entry>
|
|
<entry>blocks</entry>
|
|
<entry>number of 512-byte blocks allocated **</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
* On Windows this will always be 0.
|
|
</para>
|
|
<para>
|
|
** Only valid on systems supporting the st_blksize type - other
|
|
systems (e.g. Windows) return -1.
|
|
</para>
|
|
<para>
|
|
In case of error, <function>stat</function> returns &false;.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
Upon failure, an <constant>E_WARNING</constant> is emitted.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>4.0.6</entry>
|
|
<entry>
|
|
In addition to returning these attributes in a numeric array, they
|
|
can be accessed with associative indices, as noted next to each
|
|
parameter
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>stat</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
/* Get file stat */
|
|
$stat = stat('C:\php\php.exe');
|
|
|
|
/*
|
|
* Print file access time, this is the same
|
|
* as calling fileatime()
|
|
*/
|
|
echo 'Access time: ' . $stat['atime'];
|
|
|
|
/*
|
|
* Print file modification time, this is the
|
|
* same as calling filemtime()
|
|
*/
|
|
echo 'Modification time: ' . $stat['mtime'];
|
|
|
|
/* Print the device number */
|
|
echo 'Device number: ' . $stat['dev'];
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Using <function>stat</function> information together with <function>touch</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
/* Get file stat */
|
|
$stat = stat('C:\php\php.exe');
|
|
|
|
/* Did we failed to get stat information? */
|
|
if (!$stat) {
|
|
echo 'stat() call failed...';
|
|
} else {
|
|
/*
|
|
* We want the access time to be 1 week
|
|
* after the current access time.
|
|
*/
|
|
$atime = $stat['atime'] + 604800;
|
|
|
|
/* Touch the file */
|
|
if (!touch('some_file.txt', time(), $atime)) {
|
|
echo 'Failed to touch file...';
|
|
} else {
|
|
echo 'touch() returned success...';
|
|
}
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
¬e.filesystem-time-res;
|
|
¬e.clearstatcache;
|
|
&tip.fopen-wrapper.stat;
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>lstat</function></member>
|
|
<member><function>fstat</function></member>
|
|
<member><function>filemtime</function></member>
|
|
<member><function>filegroup</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- 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
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|