array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'en', ), 'this' => array ( 0 => 'class.ffi.php', 1 => 'FFI', ), 'up' => array ( 0 => 'book.ffi.php', 1 => 'FFI', ), 'prev' => array ( 0 => 'ffi.examples-complete.php', 1 => 'A Complete PHP/FFI/preloading Example', ), 'next' => array ( 0 => 'ffi.addr.php', 1 => 'FFI::addr', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/ffi/ffi.xml', ), 'extra_header_links' => array ( 'rel' => 'alternate', 'href' => '/manual/en/feeds/class.ffi.atom', 'type' => 'application/atom+xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 7 >= 7.4.0, PHP 8)
Objects of this class are created by the factory methods FFI::cdef(), FFI::load() or FFI::scope(). Defined C variables are made available as properties of the FFI instance, and defined C functions are made available as methods of the FFI instance. Declared C types can be used to create new C data structures using FFI::new() and FFI::type().
FFI definition parsing and shared library loading may take significant time. It is not useful
to do it on each HTTP request in a Web environment. However, it is possible to preload FFI definitions
and libraries at PHP startup, and to instantiate FFI objects when necessary. Header files
may be extended with special FFI_SCOPE
defines (e.g. #define FFI_SCOPE "foo"
;
the default scope is "C") and then loaded by FFI::load() during preloading.
This leads to the creation of a persistent binding, that will be available to all the following
requests through FFI::scope().
Refer to the complete PHP/FFI/preloading example
for details.
It is possible to preload more than one C header file into the same scope.