<?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 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.umask.php',
    1 => 'umask',
    2 => 'Change le &quot;umask&quot; courant',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Fonctions sur les syst&egrave;mes de fichiers',
  ),
  'prev' => 
  array (
    0 => 'function.touch.php',
    1 => 'touch',
  ),
  'next' => 
  array (
    0 => 'function.unlink.php',
    1 => 'unlink',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/filesystem/functions/umask.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.umask" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">umask</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">umask</span> &mdash; <span class="dc-title">Change le &quot;umask&quot; courant</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.umask-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>umask</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$mask</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>umask()</strong></span> change le umask de PHP et le
   remplace par <code class="parameter">mask</code> :
   <code class="literal">mask &amp; 0777</code> puis, retourne le vieux
   umask. Lorsque PHP est utilisé comme module de serveur, le
   umask reprend sa valeur à la fin de chaque script.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.umask-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">mask</code></dt>
     <dd>
      <p class="para">
       Le nouvel umask.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.umask-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Si <code class="parameter">mask</code> est <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, 
   <span class="function"><strong>umask()</strong></span> retourne simplement l&#039;umask actuel 
   sinon l&#039;ancien umask est retourné.
  </p>
 </div>

 
 <div class="refsect1 changelog" id="refsect1-function.umask-changelog">
  <h3 class="title">Historique</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">mask</code> est désormais nullable.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.umask-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <span class="function"><strong>umask()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$old </span><span style="color: #007700">= </span><span style="color: #0000BB">umask</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">chmod</span><span style="color: #007700">(</span><span style="color: #DD0000">"/path/some_dir/some_file.txt"</span><span style="color: #007700">, </span><span style="color: #0000BB">0755</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">umask</span><span style="color: #007700">(</span><span style="color: #0000BB">$old</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Vérification<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">$old </span><span style="color: #007700">!= </span><span style="color: #0000BB">umask</span><span style="color: #007700">()) {<br />    die(</span><span style="color: #DD0000">'Une erreur est survenue lors de la modification des droits'</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.umask-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Évitez d&#039;utiliser cette fonction sur un serveur Web multithreadé.
    Il vaut mieux changer les droits d&#039;un dossier avec la fonction 
    <span class="function"><a href="function.chmod.php" class="function">chmod()</a></span>, après la création du dossier. En utilisant
    <span class="function"><strong>umask()</strong></span>, il y a un risque de rencontrer des comportements
    indéfinis au niveau des autres scripts et du serveur, car ils utilisent
    tous le même umask.
   </p>
  </p></blockquote>
 </div>


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