<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.ffi.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ru',
  ),
  'this' => 
  array (
    0 => 'ffi.new.php',
    1 => 'FFI::new',
    2 => 'Создаёт структуру данных C',
  ),
  'up' => 
  array (
    0 => 'class.ffi.php',
    1 => 'FFI',
  ),
  'prev' => 
  array (
    0 => 'ffi.memset.php',
    1 => 'FFI::memset',
  ),
  'next' => 
  array (
    0 => 'ffi.scope.php',
    1 => 'FFI::scope',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ru',
    'path' => 'reference/ffi/ffi/new.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="ffi.new" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">FFI::new</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.4.0, PHP 8)</p><p class="refpurpose"><span class="refname">FFI::new</span> &mdash; <span class="dc-title">Создаёт структуру данных C</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-ffi.new-description">
  <h3 class="title">Описание</h3>
 <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>FFI::new</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="class.ffi-ctype.php" class="type FFI\CType">FFI\CType</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$type</code></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$owned</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$persistent</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="class.ffi-cdata.php" class="type FFI\CData">FFI\CData</a></span></span></div>

  <p class="simpara">
   Метод создаёт собственную структуру данных заданного типа.
   Разрешён любой тип, который объявили для экземпляра.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-ffi.new-parameters">
  <h3 class="title">Список параметров</h3>
  <dl>
   
    <dt><code class="parameter">type</code></dt>
    <dd>
     <span class="simpara">
      <code class="parameter">type</code> — допустимое объявление типа С в виде строки (<span class="type"><a href="language.types.string.php" class="type string">string</a></span>)
      или экземпляр класса <span class="classname"><a href="class.ffi-ctype.php" class="classname">FFI\CType</a></span>,
      которые создали заранее.
     </span>
    </dd>
   
   
    <dt><code class="parameter">owned</code></dt>
    <dd>
     <span class="simpara">
      Создавать ли управляемые или неуправляемые данные. Управляемые
      данные живут в связке с возвращённым объектом
      <span class="classname"><a href="class.ffi-cdata.php" class="classname">FFI\CData</a></span> и высвобождаются, когда
      стандартный подсчёт ссылок PHP или сборщик мусора GC освободят
      последнюю ссылку на этот объект.
      Неуправляемые данные необходимо высвобождать вручную
      методом <span class="methodname"><a href="ffi.free.php" class="methodname">FFI::free()</a></span>.
     </span>
    </dd>
   
   
    <dt><code class="parameter">persistent</code></dt>
    <dd>
     <span class="simpara">
      Располагать ли структуру данных C в системной куче (heap)
      через функцию <span class="function"><strong>malloc()</strong></span> или в куче PHP-запроса
      через функцию <span class="function"><strong>emalloc()</strong></span>.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-ffi.new-returnvalues">
  <h3 class="title">Возвращаемые значения</h3>
  <p class="simpara">
   Метод возвращает новый объект класса <span class="classname"><a href="class.ffi-cdata.php" class="classname">FFI\CData</a></span>
   или <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> в случае возникновения ошибки.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-ffi.new-changelog">
  <h3 class="title">Список изменений</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Версия</th>
      <th>Описание</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.3.0</td>
      <td>
       Статический вызов метода <span class="methodname"><strong>FFI::new()</strong></span> устарел.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>



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