W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
(PHP 7 >= 7.4.0, PHP 8)
通過(guò)工廠方法 FFI::cdef()、FFI::load() 或 FFI::scope() 創(chuàng)建該類的對(duì)象。定義的 C 變量作為有效的 FFI 實(shí)例屬性,定義的 C 函數(shù)作為有效的 FFI 實(shí)例方法。聲明的 C 類型可以用于 FFI::new() 和 FFI::type() 創(chuàng)建新的 C 數(shù)據(jù)結(jié)構(gòu)。
FFI 定義解析和共享庫(kù)加載可能需要較長(zhǎng)時(shí)間。在 Web 環(huán)境中,每個(gè) HTTP 請(qǐng)求都進(jìn)行這些操作是沒(méi)有意義的。然而,在 PHP 啟動(dòng)時(shí)預(yù)加載 FFI 定義和庫(kù),并在需要時(shí)實(shí)例化 FFI 對(duì)象是可能的。header 文件可以使用特殊的 FFI_SCOPE 定義進(jìn)行擴(kuò)展(例如 #define FFI_SCOPE "foo"”"),然后在預(yù)加載期間由 FFI::load() 加載。這將創(chuàng)建持久綁定,將通過(guò) FFI::scope() 在所有后續(xù)請(qǐng)求中可用。有關(guān)詳細(xì)信息,請(qǐng)參閱完整的 PHP/FFI/preloading 示例。
可以將多個(gè) C header 文件預(yù)加載到同一作用域中。
final class FFI {
/* 常量 */
public const int __BIGGEST_ALIGNMENT__;
/* 方法 */
public static addr(FFI\CData &$ptr): FFI\CData
public static alignof(FFI\CData|FFI\CType &$ptr): int
public static arrayType(FFI\CType $type, array $dimensions): FFI\CType
public static cast(FFI\CType|string $type, FFI\CData|int|float|bool|null &$ptr): ?FFI\CData
public cast(FFI\CType|string $type, FFI\CData|int|float|bool|null &$ptr): ?FFI\CData
public static cdef(string $code = "", ?string $lib = null): FFI
public static free(FFI\CData &$ptr): void
public static isNull(FFI\CData &$ptr): bool
public static load(string $filename): ?FFI
public static memcmp(string|FFI\CData &$ptr1, string|FFI\CData &$ptr2, int $size): int
public static memcpy(FFI\CData &$to, FFI\CData|string &$from, int $size): void
public static memset(FFI\CData &$ptr, int $value, int $size): void
public static new(FFI\CType|string $type, bool $owned = true, bool $persistent = false): ?FFI\CData
public new(FFI\CType|string $type, bool $owned = true, bool $persistent = false): ?FFI\CData
public static scope(string $name): FFI
public static sizeof(FFI\CData|FFI\CType &$ptr): int
public static string(FFI\CData &$ptr, ?int $size = null): string
public static type(string $type): ?FFI\CType
public type(string $type): ?FFI\CType
public static typeof(FFI\CData &$ptr): FFI\CType
}
FFI::__BIGGEST_ALIGNMENT__
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: