总有人间一两风,填我十万八千梦

PHP FFI 用法 手册 | 示例代码

PHP开发手册 归档 338℃ 0评论

Main interface to C code and data

(PHP 7 >= 7.4.0)

简介

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.

类摘要

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

}

属性/方法 列表

用户贡献的笔记

There are no user contributed notes for this page.

转载请注明:悠然品鉴 » PHP FFI 用法 手册 | 示例代码

喜欢 (0)or分享 (0)
发表我的评论
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址