[php-src] Issue #7866: Ability to pick PHP value by reference in FFI.
| From: | userqq | Date: | Sat, 01 Jan 2022 17:49:36 +0000 |
| Subject: | [php-src] Issue #7866: Ability to pick PHP value by reference in FFI. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-238702@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7866
Comment Author: userqq
HI @cmb69, It could work in this case, thank you!
But in my case I using FFI without libraries, as alternative to
unpack() - it seems
faster to me, if I measured correctly.
E.g.:
```php
$int = FFI::new('int32_t');
$data = fread($h, 4);
FFI::memcpy($int, $data, 4);
var_dump($int->cdata);
```
Or even with structs:
```php
$header = FFI::new('struct {
int64_t authKeyId;
int64_t messageId;
int32_t length;
}');
$data = fread($h, 20);
FFI::memcpy($plainHeader, $data, 20);
var_dump($header->length);
```