<?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 => 'en',
  ),
  'this' => 
  array (
    0 => 'ffi.load.php',
    1 => 'FFI::load',
    2 => 'Loads C declarations from a C header file',
  ),
  'up' => 
  array (
    0 => 'class.ffi.php',
    1 => 'FFI',
  ),
  'prev' => 
  array (
    0 => 'ffi.isnull.php',
    1 => 'FFI::isNull',
  ),
  'next' => 
  array (
    0 => 'ffi.memcmp.php',
    1 => 'FFI::memcmp',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/ffi/ffi/load.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="ffi.load" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">FFI::load</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.4.0, PHP 8)</p><p class="refpurpose"><span class="refname">FFI::load</span> &mdash; <span class="dc-title">Loads C declarations from a C header file</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-ffi.load-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>FFI::load</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="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="class.ffi.php" class="type FFI">FFI</a></span></span></div>

  <p class="simpara">
   Loads C declarations from a C header file. It is possible to specify shared libraries that should be loaded,
   using special <code class="literal">FFI_LIB</code> defines in the loaded C header file.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-ffi.load-parameters">
  <h3 class="title">Parameters</h3>
  <dl>
   
    <dt><code class="parameter">filename</code></dt>
    <dd>
     <span class="simpara">
      The name of a C header file.
     </span>
     <span class="simpara">
      C preprocessor directives are not supported, i.e. <code class="literal">#include</code>,
      <code class="literal">#define</code> and CPP macros do not work, except for special cases
      listed below.
     </span>
     <span class="simpara">
      The header file <em>should</em> contain a <code class="literal">#define</code> statement for the
      <code class="literal">FFI_SCOPE</code> variable, e.g.: <code class="code">#define FFI_SCOPE &quot;MYLIB&quot;</code>.
      Refer to the <a href="class.ffi.php#ffi.intro" class="link">class introduction</a> for details.
     </span>
     <span class="simpara">
      The header file <em>may</em> contain a <code class="literal">#define</code> statement for the
      <code class="literal">FFI_LIB</code> variable to specify the library it exposes. If it is
      a system library only the file name is required, e.g.: <code class="code">#define FFI_LIB
      &quot;libc.so.6&quot;</code>.  If it is a custom library, a relative path is required,
      e.g.: <code class="code">#define FFI_LIB &quot;./mylib.so&quot;</code>.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-ffi.load-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="simpara">
   Returns the freshly created <span class="classname"><a href="class.ffi.php" class="classname">FFI</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.load-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.3.0</td>
      <td>
       <span class="methodname"><strong>FFI::load()</strong></span> is now allowed in
       <a href="opcache.preloading.php" class="link">preload scripts</a> when the
       current system user is the same as the one defined in the
       <code class="literal">opcache.preload_user</code> configuration directive.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-ffi.load-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="ffi.scope.php" class="methodname" rel="rdfs-seeAlso">FFI::scope()</a> - Instantiates an FFI object with C declarations parsed during preloading</span></li>
  </ul>
 </div>


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