略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: FFI::cast

2024-11-14

FFI::cast

(PHP 7 >= 7.4.0, PHP 8)

FFI::castPerforms a C type cast

说明

public static FFI::cast(FFI\CType|string $type, FFI\CData|int|float|bool|null &$ptr): ?FFI\CData
public FFI::cast(FFI\CType|string $type, FFI\CData|int|float|bool|null &$ptr): ?FFI\CData

FFI::cast() creates a new FFI\CData object, that references the same C data structure, but is associated with a different type. The resulting object does not own the C data, and the source ptr must survive the result. The C type may be specified as a string with any valid C type declaration or as FFI\CType object, created before. If this method is called statically, it must only use predefined C type names (e.g. int, char, etc.); if the method is called as instance method, any type declared for the instance is allowed.

参数

type

A valid C declaration as string, or an instance of FFI\CType which has already been created.

ptr

The handle of the pointer to a C data structure.

返回值

Returns the freshly created FFI\CData object.

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/ffi.cast.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3