<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.errorfunc.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ru',
  ),
  'this' => 
  array (
    0 => 'function.debug-backtrace.php',
    1 => 'debug_backtrace',
    2 => 'Генерирует обратную трассировку вызовов функций',
  ),
  'up' => 
  array (
    0 => 'ref.errorfunc.php',
    1 => 'Функции обработки ошибок',
  ),
  'prev' => 
  array (
    0 => 'ref.errorfunc.php',
    1 => 'Функции обработки ошибок',
  ),
  'next' => 
  array (
    0 => 'function.debug-print-backtrace.php',
    1 => 'debug_print_backtrace',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ru',
    'path' => 'reference/errorfunc/functions/debug-backtrace.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.debug-backtrace" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">debug_backtrace</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">debug_backtrace</span> &mdash; <span class="dc-title">Генерирует обратную трассировку вызовов функций</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.debug-backtrace-description">
  <h3 class="title">Описание</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>debug_backtrace</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$options</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.debug-backtrace-provide-object">DEBUG_BACKTRACE_PROVIDE_OBJECT</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$limit</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="para rdfs-comment">
   Функция <span class="function"><strong>debug_backtrace()</strong></span> генерирует обратный стек вызовов PHP-функций.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.debug-backtrace-parameters">
  <h3 class="title">Список параметров</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <p class="para">
       Параметр принимает битовую маску из следующих опций:
       <table class="doctable table">
        <caption><strong>Опции функции <span class="function"><strong>debug_backtrace()</strong></span></strong></caption>
        
         <tbody class="tbody">
          <tr>
           <td>DEBUG_BACKTRACE_PROVIDE_OBJECT</td>
           <td>
            Опция устанавливает бит, который определяет, заполнять ли ключ &quot;object&quot; в выходном массиве.
           </td>
          </tr>

          <tr>
           <td>DEBUG_BACKTRACE_IGNORE_ARGS</td>
           <td>
            Опция устанавливает бит, который определяет, исключать ли ключ &quot;args&quot; из выходного массива
            и вместе с ним аргументы функций и методов, чтобы уменьшить расход памяти.
           </td>
          </tr>

         </tbody>
        
       </table>

       <blockquote class="note"><p><strong class="note">Замечание</strong>: 
        <p class="para">
         Объединение опций даёт четыре возможные комбинации:
         <table class="doctable table">
          <caption><strong>Комбинации опций функции <span class="function"><strong>debug_backtrace()</strong></span></strong></caption>
          
           <tbody class="tbody">
            <tr>
             <td><code class="code">debug_backtrace()</code></td>
             <td rowspan="3" style="vertical-align: middle;">
              Заполняются оба ключа.
             </td>
            </tr>

            <tr>
             <td><code class="code">debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT)</code></td>
            </tr>

            <tr>
             <td><code class="code">debug_backtrace(1)</code></td>
            </tr>

            <tr>
             <td><code class="code">debug_backtrace(0)</code></td>
             <td style="vertical-align: middle;">
              Не включается ключ <code class="literal">&quot;object&quot;</code> и заполняется ключ <code class="literal">&quot;args&quot;</code>.
             </td>
            </tr>

            <tr>
             <td><code class="code">debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)</code></td>
             <td rowspan="2" style="vertical-align: middle;">
              Опускается ключ <code class="literal">&quot;object&quot;</code> <em>и</em> ключ <code class="literal">&quot;args&quot;</code>.
             </td>
            </tr>

            <tr>
             <td><code class="code">debug_backtrace(2)</code></td>
            </tr>

            <tr>
             <td><code class="code">debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT|DEBUG_BACKTRACE_IGNORE_ARGS)</code></td>
             <td rowspan="2" style="vertical-align: middle;">
              Заполняется ключ <code class="literal">&quot;object&quot;</code> <em>и</em> опускается ключ <code class="literal">&quot;args&quot;</code>.
             </td>
            </tr>

            <tr>
             <td><code class="code">debug_backtrace(3)</code></td>
            </tr>

           </tbody>
          
         </table>

        </p>
       </p></blockquote>
      </p>
     </dd>
    
    
     <dt><code class="parameter">limit</code></dt>
     <dd>
      <p class="para">
       Параметр ограничивает количество кадров стека в выходном массиве.
       Со значением по умолчанию —
       <code class="parameter">limit</code>=<code class="literal">0</code> — возвращается весь стек вызовов функций.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.debug-backtrace-returnvalues">
  <h3 class="title">Возвращаемые значения</h3>
  <p class="para">
   Функция возвращает массив вложенных ассоциативных массивов (<span class="type"><a href="language.types.array.php" class="type array">array</a></span>).
   Следующая таблица приводит список возможных элементов выходного массива:
  </p>
  <p class="para">
   <table class="doctable table">
    <caption><strong>
     Возможные элементы массивов в результатах функции
     <span class="function"><strong>debug_backtrace()</strong></span>
    </strong></caption>
    
     <thead>
      <tr>
       <th>Имя</th>
       <th>Тип</th>
       <th>Описание</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>function</td>
       <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
       <td>
        Название текущей функции. Смотрите также описание константы
        <a href="language.constants.magic.php" class="link">__FUNCTION__</a>.
       </td>
      </tr>

      <tr>
       <td>line</td>
       <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
       <td>
        Текущий номер строки. Смотрите также описание константы
        <a href="language.constants.magic.php" class="link">__LINE__</a>.
       </td>
      </tr>

      <tr>
       <td>file</td>
       <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
       <td>
        Название текущего файла. Смотрите также описание константы
        <a href="language.constants.magic.php" class="link">__FILE__</a>.
       </td>
      </tr>

      <tr>
       <td>class</td>
       <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
       <td>
        Название текущего <a href="language.oop5.php" class="link">класса</a>. Смотрите также
        описание константы <a href="language.constants.magic.php" class="link">__CLASS__</a>.
       </td>
      </tr>

      <tr>
       <td>object</td>
       <td><span class="type"><a href="language.types.object.php" class="type object">object</a></span></td>
       <td>
        Текущий <a href="language.oop5.php" class="link">объект</a>.
       </td>
      </tr>

      <tr>
       <td>type</td>
       <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
       <td>
        Текущий тип вызова функции. При вызове метода объекта функция
        возвращает значение &quot;-&gt;&quot;. При вызове статического метода класса возвращается &quot;::&quot;.
        При вызове функции ничего не возвращается.
       </td>
      </tr>

      <tr>
       <td>args</td>
       <td><span class="type"><a href="language.types.array.php" class="type array">array</a></span></td>
       <td>
        При вызове этой функции внутри другой функции элементы с этим ключом
        содержат списки аргументов функций.
        При вызове внутри включаемого файла
        элемент содержит названия включённых файлов.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.debug-backtrace-examples">
  <h3 class="title">Примеры</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Пример #1 Пример генерации обратной трассировки вызовов функцией <span class="function"><strong>debug_backtrace()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">// Файл: /tmp/a.php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">a_test</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">)<br />{<br />    echo </span><span style="color: #DD0000">"\nПривет, </span><span style="color: #0000BB">$str</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />    </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">debug_backtrace</span><span style="color: #007700">());<br />}<br /><br /></span><span style="color: #0000BB">a_test</span><span style="color: #007700">(</span><span style="color: #DD0000">'друг'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;<br /></span><br /><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">// Файл: /tmp/b.php<br /></span><span style="color: #007700">include_once </span><span style="color: #DD0000">'/tmp/a.php'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>
     При выполнении файла <var class="filename">/tmp/b.php</var>
     PHP выведет результат наподобие такого:
    </p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Привет, друг
array(2) {
[0]=&gt;
array(4) {
    [&quot;file&quot;] =&gt; string(10) &quot;/tmp/a.php&quot;
    [&quot;line&quot;] =&gt; int(10)
    [&quot;function&quot;] =&gt; string(6) &quot;a_test&quot;
    [&quot;args&quot;]=&gt;
    array(1) {
      [0] =&gt; &amp;string(8) &quot;друг&quot;
    }
}
[1]=&gt;
array(4) {
    [&quot;file&quot;] =&gt; string(10) &quot;/tmp/b.php&quot;
    [&quot;line&quot;] =&gt; int(2)
    [&quot;args&quot;] =&gt;
    array(1) {
      [0] =&gt; string(10) &quot;/tmp/a.php&quot;
    }
    [&quot;function&quot;] =&gt; string(12) &quot;include_once&quot;
  }
}</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.debug-backtrace-seealso">
  <h3 class="title">Смотрите также</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.trigger-error.php" class="function" rel="rdfs-seeAlso">trigger_error()</a> - Генерирует предупреждение, уведомление или сообщение об ошибке на уровне пользователя</span></li>
    <li><span class="function"><a href="function.debug-print-backtrace.php" class="function" rel="rdfs-seeAlso">debug_print_backtrace()</a> - Выводит обратную трассировку вызовов функций</span></li>
   </ul>
  </p>
 </div>

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