vagrant@homestead:~/phpffi/helloworld$ ls
helloworld.c helloworld.php
libhelloworld.sovagrant@homestead:~/phpffi/helloworld$ cat helloworld.{c,php}
#include <stdio.h>
void helloworld()
{
printf("hello world!\n");
}
<?php
$ffi = ffi::cdef(
"void helloworld();",
"./
libhelloworld.so"
);
$ffi->helloworld();
vagrant@homestead:~/phpffi/helloworld$ php helloworld.php
hello world!
vagrant@homestead:~/phpffi/helloworld$ php --version
PHP 7.4.11 (cli) (built: Oct 10 2020 19:44:50) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.11, Copyright (c), by Zend Technologies
vagrant@homestead:~/phpffi/helloworld$ php -m | grep -i ffi
FFI