cvs: phpdoc-zh /reference/filesystem/functions fileperms.xml
| From: | liuming | Date: | Tue, 16 Aug 2005 04:40:46 +0000 |
| Subject: | cvs: phpdoc-zh /reference/filesystem/functions fileperms.xml | ||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-2311@lists.php.net to get a copy of this message | ||
lm92 Tue Aug 16 00:40:46 2005 EDT
Modified files:
/phpdoc-zh/reference/filesystem/functions fileperms.xml
Log:
updated to en version
http://cvs.php.net/diff.php/phpdoc-zh/reference/filesystem/functions/fileperms.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc-zh/reference/filesystem/functions/fileperms.xml
diff -u phpdoc-zh/reference/filesystem/functions/fileperms.xml:1.3
phpdoc-zh/reference/filesystem/functions/fileperms.xml:1.4
--- phpdoc-zh/reference/filesystem/functions/fileperms.xml:1.3 Mon Feb 24 04:12:29 2003
+++ phpdoc-zh/reference/filesystem/functions/fileperms.xml Tue Aug 16 00:40:45 2005
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="gb2312"?>
-<!-- $Revision: 1.3 $ -->
-<!-- $Author: dallas $ -->
-<!-- EN-Revision: 1.3 Maintainer: dallas Status: ready -->
+<!-- $Revision: 1.4 $ -->
+<!-- $Author: lm92 $ -->
+<!-- EN-Revision: 1.9 Maintainer: dallas Status: ready -->
<refentry id="function.fileperms">
<refnamediv>
<refname>fileperms</refname>
@@ -17,7 +17,90 @@
·µ»ØÎļþµÄ·ÃÎÊȨÏÞ£¬Èç¹û³ö´íÔò·µ»Ø &false;¡£
</para>
¬e.clearstatcache;
- ¬e.no-remote;
+ &tip.fopen-wrapper.stat;
+ <example>
+ <title>Ò԰˽øÖƵÄÐÎʽÏÔʾÎļþµÄȨÏÞ</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+echo substr(sprintf('%o', fileperms('/tmp')), -4);
+echo substr(sprintf('%o', fileperms('/etc/passwd')), -4);
+?>
+]]>
+ </programlisting>
+ <para>ÉÏÀý½«Êä³ö£º</para>
+ <screen>
+<![CDATA[
+1777
+0644
+]]>
+ </screen>
+ </example>
+ <example>
+ <title>Êä³öÈ«²¿È¨ÏÞ</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$perms = fileperms('/etc/passwd');
+
+if (($perms & 0xC000) == 0xC000) {
+ // Socket
+ $info = 's';
+} elseif (($perms & 0xA000) == 0xA000) {
+ // Symbolic Link
+ $info = 'l';
+} elseif (($perms & 0x8000) == 0x8000) {
+ // Regular
+ $info = '-';
+} elseif (($perms & 0x6000) == 0x6000) {
+ // Block special
+ $info = 'b';
+} elseif (($perms & 0x4000) == 0x4000) {
+ // Directory
+ $info = 'd';
+} elseif (($perms & 0x2000) == 0x2000) {
+ // Character special
+ $info = 'c';
+} elseif (($perms & 0x1000) == 0x1000) {
+ // FIFO pipe
+ $info = 'p';
+} else {
+ // Unknown
+ $info = 'u';
+}
+
+// Owner
+$info .= (($perms & 0x0100) ? 'r' : '-');
+$info .= (($perms & 0x0080) ? 'w' : '-');
+$info .= (($perms & 0x0040) ?
+ (($perms & 0x0800) ? 's' : 'x' ) :
+ (($perms & 0x0800) ? 'S' : '-'));
+
+// Group
+$info .= (($perms & 0x0020) ? 'r' : '-');
+$info .= (($perms & 0x0010) ? 'w' : '-');
+$info .= (($perms & 0x0008) ?
+ (($perms & 0x0400) ? 's' : 'x' ) :
+ (($perms & 0x0400) ? 'S' : '-'));
+
+// World
+$info .= (($perms & 0x0004) ? 'r' : '-');
+$info .= (($perms & 0x0002) ? 'w' : '-');
+$info .= (($perms & 0x0001) ?
+ (($perms & 0x0200) ? 't' : 'x' ) :
+ (($perms & 0x0200) ? 'T' : '-'));
+
+echo $info;
+?>
+]]>
+ </programlisting>
+ <para>ÉÏÀý½«Êä³ö£º</para>
+ <screen>
+<![CDATA[
+-r--r--r--
+]]>
+ </screen>
+ </example>
<simpara>
²Î¼û <function>is_readable</function> ºÍ
<function>stat</function>¡£
</simpara>