<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.15 $ -->
<!-- splitted from ./en/functions/filesystem.xml, last change in rev 1.2 -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.chmod">
 <refnamediv>
  <refname>chmod</refname>
  <refpurpose>Changes file mode</refpurpose>
 </refnamediv>
 <refsect1>
  <title>Description</title>
  <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 file specified by
   <parameter>filename</parameter> to that given in
   <parameter>mode</parameter>.
  </para>
  <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 'man 1 chmod' and 'man 2 chmod'.
  </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>
  <para>
   &return.success;
  </para>
  <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>
  &note.no-remote;
  <note>
   <simpara>
    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.
   </simpara>
  </note>
  <para>
   See also <function>chown</function> and
   <function>chgrp</function>.
  </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:"../../../../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
-->