PHP code example of ffi / var-dumper
1. Go to this page and download the library: Download ffi/var-dumper library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ffi / var-dumper example snippets
dump(\FFI::new('struct { float x }'));
//
// Expected Output:
//
// struct <anonymous> {
// x<float>: 0.0
// }
//
// Create char* with "Hello World!\0" string.
$string = \FFI::new('char[13]');
\FFI::memcpy($string, 'Hello World!', 12);
$pointer = \FFI::cast('char*', $string);
// Dump
dump($pointer);
// VAR_DUMPER_FFI_UNSAFE=0
//
// > char* (unsafe access) {
// > +0: "H"
// > }
// VAR_DUMPER_FFI_UNSAFE=1
//
// > b"Hello World!\x00"