PHP, \FFI::
cdef()->
new('void (*)(int a, const char* b)'
));
} public function testCastNonCuttedPointerToChar() { $actualMessage = "Hello World!\0";
$string = \FFI::
cdef()->
new('char[100]'
);
$pointer = \FFI::
addr($string[0
]);
\FFI::
memcpy($pointer,
$actualMessage, \
strlen($actualMessage));
$this->
assertDumpEquals(<<<'PHP'
FFI\CData<char*> size 8 align 8 {
cdata: "Hello World!\x00"
}
PHP,
$pointer);
} public function testCastCuttedPointerToChar() { $actualMessage =
str_repeat('Hello World!', 30
)."\0";