<?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 => 'zh',
  ),
  'this' => 
  array (
    0 => 'ffi.new.php',
    1 => 'FFI::new',
    2 => 'Creates a C data structure',
  ),
  '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' => 'en',
    '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">Creates a C data structure</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">
   Creates a native data structure of the given C type.
   Any type declared for the instance is allowed.
  </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> is a valid C declaration as <span class="type"><a href="language.types.string.php" class="type string">string</a></span>, or an
      instance of <span class="classname"><a href="class.ffi-ctype.php" class="classname">FFI\CType</a></span> which has already been created.
     </span>
    </dd>
   
   
    <dt><code class="parameter">owned</code></dt>
    <dd>
     <span class="simpara">
      Whether to create owned (i.e. managed) or unmanaged data. Managed data lives together
      with the returned <span class="classname"><a href="class.ffi-cdata.php" class="classname">FFI\CData</a></span> object, and is released when the
      last reference to that object is released by regular PHP reference counting or GC.
      Unmanaged data should be released by calling <span class="methodname"><a href="ffi.free.php" class="methodname">FFI::free()</a></span>,
      when no longer needed.
     </span>
    </dd>
   
   
    <dt><code class="parameter">persistent</code></dt>
    <dd>
     <span class="simpara">
      Whether to allocate the C data structure permanently on the system heap (using
      <span class="function"><strong>malloc()</strong></span>), or on the PHP request heap (using <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">
   Returns the freshly created <span class="classname"><a href="class.ffi-cdata.php" class="classname">FFI\CData</a></span> object,
   or <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> on failure.
  </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>
       Calling <span class="methodname"><strong>FFI::new()</strong></span> statically is now deprecated.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


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