mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-19 10:28:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@297028 c90b9560-bf6c-de11-be94-00142212c4b1
155 lines
4.4 KiB
XML
155 lines
4.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.chmod">
|
|
<refnamediv>
|
|
<refname>chmod</refname>
|
|
<refpurpose>Changes file mode</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>chmod</methodname>
|
|
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>mode</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Attempts to change the mode of the specified file to that given in
|
|
<parameter>mode</parameter>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>filename</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Path to the file.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>mode</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Note that <parameter>mode</parameter> is not automatically
|
|
assumed to be an octal value, so strings (such as "g+w") will
|
|
not work properly. To ensure the expected operation,
|
|
you need to prefix <parameter>mode</parameter> with a zero (0):
|
|
</para>
|
|
<para>
|
|
<informalexample>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
chmod("/somedir/somefile", 755); // decimal; probably incorrect
|
|
chmod("/somedir/somefile", "u+rwx,go+rx"); // string; incorrect
|
|
chmod("/somedir/somefile", 0755); // octal; correct value of mode
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
</para>
|
|
<para>
|
|
The <parameter>mode</parameter> parameter consists of three octal
|
|
number components specifying access restrictions for the owner,
|
|
the user group in which the owner is in, and to everybody else in
|
|
this order. One component can be computed by adding up the needed
|
|
permissions for that target user base. Number 1 means that you
|
|
grant execute rights, number 2 means that you make the file
|
|
writeable, number 4 means that you make the file readable. Add
|
|
up these numbers to specify needed rights. You can also read more
|
|
about modes on Unix systems with '<command>man 1 chmod</command>'
|
|
and '<command>man 2 chmod</command>'.
|
|
</para>
|
|
<para>
|
|
<informalexample>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// Read and write for owner, nothing for everybody else
|
|
chmod("/somedir/somefile", 0600);
|
|
|
|
// Read and write for owner, read for everybody else
|
|
chmod("/somedir/somefile", 0644);
|
|
|
|
// Everything for owner, read and execute for others
|
|
chmod("/somedir/somefile", 0755);
|
|
|
|
// Everything for owner, read and execute for owner's group
|
|
chmod("/somedir/somefile", 0750);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
The current user is the user under which PHP runs. It is probably not the
|
|
same user you use for normal shell or FTP access. The mode can be changed
|
|
only by user who owns the file on most systems.
|
|
</para>
|
|
</note>
|
|
¬e.no-remote;
|
|
<note>
|
|
<para>
|
|
When &safemode; is enabled, PHP checks whether the files or directories
|
|
you are about to operate on have the same UID (owner) as the script that
|
|
is being executed. In addition, you cannot set the SUID, SGID and sticky
|
|
bits.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>chown</function></member>
|
|
<member><function>chgrp</function></member>
|
|
<member><function>fileperms</function></member>
|
|
<member><function>stat</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
|
|
-->
|