Rechercher une fonction PHP

Main interface to C code and data

(PHP 7 >= 7.4.0)

Introduction

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.

PHP: FFI - Manual Home of Manuel PHP  Contents Haut

Class synopsis

FFI {
/* Methods */
public static addr ( FFI\CData &$ptr ) : FFI\CData
public static alignof ( mixed &$ptr ) : int
public static arrayType ( FFI\CType $type , array $dims ) : FFI\CType
public static cast ( mixed $type , FFI\CData &$ptr ) : FFI\CData
public cast ( mixed $type , FFI\CData &$ptr ) : FFI\CData
public static cdef ([ string $code = "" [, string $lib ]] ) : FFI
public static free ( FFI\CData &$ptr ) : void
public static load ( string $filename ) : FFI
public static memcmp ( mixed &$ptr1 , mixed &$ptr2 , int $size ) : int
public static memcpy ( FFI\CData &$dst , mixed &$src , int $size ) : void
public static memset ( FFI\CData &$ptr , int $ch , int $size ) : void
public static new ( mixed $type [, bool $owned = TRUE [, bool $persistent = FALSE ]] ) : FFI\CData
public new ( mixed $type [, bool $owned = TRUE [, bool $persistent = FALSE ]] ) : FFI\CData
public static scope ( string $scope_name ) : FFI
public static sizeof ( mixed &$ptr ) : int
public static string ( FFI\CData &$ptr [, int $size ] ) : string
public static type ( mixed $type ) : FFI\CType
public type ( mixed $type ) : FFI\CType
public static typeof ( FFI\CData &$ptr ) : FFI\CType
}

PHP: FFI - Manual Home of Manuel PHP  Contents Haut

Table of Contents

Find a PHP function

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-class.ffi.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : http://php.net

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut