<?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 => 'ru',
  ),
  'this' => 
  array (
    0 => 'function.unlink.php',
    1 => 'unlink',
    2 => 'Удаляет файл',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Функции файловой системы',
  ),
  'prev' => 
  array (
    0 => 'function.umask.php',
    1 => 'umask',
  ),
  'next' => 
  array (
    0 => 'book.inotify.php',
    1 => 'Inotify',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ru',
    'path' => 'reference/filesystem/functions/unlink.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.unlink" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">unlink</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">unlink</span> &mdash; <span class="dc-title">Удаляет файл</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.unlink-description">
  <h3 class="title">Описание</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>unlink</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"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span></span> <code class="parameter">$context</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.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Функция удаляет файл <code class="parameter">filename</code>. Функция похожа на функцию
   unlink() в языке C на системах Unix. При неудачном выполнении функция вызовет ошибку уровня
   <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.unlink-parameters">
  <h3 class="title">Список параметров</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">filename</code></dt>
     <dd>
      <p class="para">
       Путь к файлу.
      </p>
      <p class="para">
       Функция удалит символическую ссылку, если файл — символическая ссылка.
       Чтобы удалить символическую ссылку на каталог в ОС Windows, вместо этой
       функции вызывают функцию <span class="function"><a href="function.rmdir.php" class="function">rmdir()</a></span>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">context</code></dt>
     <dd>
      <p class="para">Ресурс (<span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>)
<a href="stream.contexts.php" class="link">контекста потока</a>.</p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.unlink-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 changelog" id="refsect1-function.unlink-changelog">
  <h3 class="title">Список изменений</h3>
 <table class="doctable informaltable">
  
   <thead>
    <tr>
     <th>Версия</th>
     <th>Описание</th>
    </tr>

   </thead>

   <tbody class="tbody">
    <tr>
     <td>7.3.0</td>
     <td>
      В ОС Windows теперь можно удалить файлы функцией <span class="function"><strong>unlink()</strong></span>
      через дескрипторы, хотя раньше это не удавалось. Тем не менее, всё ещё
      невозможно повторно создать удалённый файл, пока все дескрипторы к нему не будут
      закрыты.
     </td>
    </tr>

   </tbody>
  
 </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.unlink-examples">
  <h3 class="title">Примеры</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Пример #1 Пример простого использования функции <span class="function"><strong>unlink()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$fh </span><span style="color: #007700">= </span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'test.html'</span><span style="color: #007700">, </span><span style="color: #DD0000">'a'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #0000BB">$fh</span><span style="color: #007700">, </span><span style="color: #DD0000">'&lt;h1&gt;Привет, мир!&lt;/h1&gt;'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fh</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">unlink</span><span style="color: #007700">(</span><span style="color: #DD0000">'test.html'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 seealso" id="refsect1-function.unlink-seealso">
  <h3 class="title">Смотрите также</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.rmdir.php" class="function" rel="rdfs-seeAlso">rmdir()</a> - Удаляет директорию</span></li>
   </ul>
  </p>
 </div>


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