<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.filesystem.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.chmod.php',
    1 => 'chmod',
    2 => 'Changes file mode',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Функції Файлової Системи',
  ),
  'prev' => 
  array (
    0 => 'function.chgrp.php',
    1 => 'chgrp',
  ),
  'next' => 
  array (
    0 => 'function.chown.php',
    1 => 'chown',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/filesystem/functions/chmod.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.chmod" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">chmod</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">chmod</span> &mdash; <span class="dc-title">Changes file mode</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.chmod-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>chmod</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$filename</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$permissions</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Attempts to change the mode of the specified file to that given in
   <code class="parameter">permissions</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.chmod-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">filename</code></dt>
     <dd>
      <p class="para">
       Path to the file.
      </p>
     </dd>
    
    
     <dt><code class="parameter">permissions</code></dt>
     <dd>
      <p class="para">
       Note that <code class="parameter">permissions</code> is not automatically
       assumed to be an octal value, so to ensure the expected operation,
       you need to prefix <code class="parameter">permissions</code> with a zero (0). 
       Strings such as &quot;g+w&quot; will not work properly.
      </p>
      <p class="para">
       <div class="informalexample">
        <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />chmod</span><span style="color: #007700">(</span><span style="color: #DD0000">"/somedir/somefile"</span><span style="color: #007700">, </span><span style="color: #0000BB">755</span><span style="color: #007700">);   </span><span style="color: #FF8000">// decimal; probably incorrect<br /></span><span style="color: #0000BB">chmod</span><span style="color: #007700">(</span><span style="color: #DD0000">"/somedir/somefile"</span><span style="color: #007700">, </span><span style="color: #DD0000">"u+rwx,go+rx"</span><span style="color: #007700">); </span><span style="color: #FF8000">// string; incorrect<br /></span><span style="color: #0000BB">chmod</span><span style="color: #007700">(</span><span style="color: #DD0000">"/somedir/somefile"</span><span style="color: #007700">, </span><span style="color: #0000BB">0755</span><span style="color: #007700">);  </span><span style="color: #FF8000">// octal; correct value of mode<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
        </div>

       </div>
      </p>
      <p class="para">
       The <code class="parameter">permissions</code> 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 &#039;<strong class="command">man 1 chmod</strong>&#039;
       and &#039;<strong class="command">man 2 chmod</strong>&#039;.
      </p>
      <p class="para">
       <div class="informalexample">
        <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Read and write for owner, nothing for everybody else<br /></span><span style="color: #0000BB">chmod</span><span style="color: #007700">(</span><span style="color: #DD0000">"/somedir/somefile"</span><span style="color: #007700">, </span><span style="color: #0000BB">0600</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Read and write for owner, read for everybody else<br /></span><span style="color: #0000BB">chmod</span><span style="color: #007700">(</span><span style="color: #DD0000">"/somedir/somefile"</span><span style="color: #007700">, </span><span style="color: #0000BB">0644</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Everything for owner, read and execute for others<br /></span><span style="color: #0000BB">chmod</span><span style="color: #007700">(</span><span style="color: #DD0000">"/somedir/somefile"</span><span style="color: #007700">, </span><span style="color: #0000BB">0755</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Everything for owner, read and execute for owner's group<br /></span><span style="color: #0000BB">chmod</span><span style="color: #007700">(</span><span style="color: #DD0000">"/somedir/somefile"</span><span style="color: #007700">, </span><span style="color: #0000BB">0750</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
        </div>

       </div>
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.chmod-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Повертає <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> у разі успіху або <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> в разі помилки.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.chmod-errors">
  <h3 class="title">Помилки/виключення</h3>
  <p class="para">
   Upon failure, an <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> is emitted.
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.chmod-notes">
  <h3 class="title">Примітки</h3>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="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.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: <span class="simpara">Ця функція незастосовна
для роботи з <a href="features.remote-files.php" class="link">віддаленими файлами</a>,
оскільки файл повинен бути доступним через файлову систему
сервера.</span></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.chmod-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.chown.php" class="function" rel="rdfs-seeAlso">chown()</a> - Changes file owner</span></li>
    <li><span class="function"><a href="function.chgrp.php" class="function" rel="rdfs-seeAlso">chgrp()</a> - Changes file group</span></li>
    <li><span class="function"><a href="function.fileperms.php" class="function" rel="rdfs-seeAlso">fileperms()</a> - Gets file permissions</span></li>
    <li><span class="function"><a href="function.stat.php" class="function" rel="rdfs-seeAlso">stat()</a> - Gives information about a file</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>