From 925f7f4a11341fb950f4f6cd6390187b780ba419 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 9 Jul 2024 08:27:57 +0900 Subject: feat: add examples/compile-php-to-wasm --- examples/compile-php-to-wasm/php-wasm.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 examples/compile-php-to-wasm/php-wasm.c (limited to 'examples/compile-php-to-wasm/php-wasm.c') diff --git a/examples/compile-php-to-wasm/php-wasm.c b/examples/compile-php-to-wasm/php-wasm.c new file mode 100644 index 0000000..9c71ca1 --- /dev/null +++ b/examples/compile-php-to-wasm/php-wasm.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +int EMSCRIPTEN_KEEPALIVE php_wasm_run(const char* code) { + zend_result result; + + int argc = 1; + char* argv[] = { "php.wasm", NULL }; + + PHP_EMBED_START_BLOCK(argc, argv); + + result = zend_eval_string_ex(code, NULL, "php.wasm code", 1); + + PHP_EMBED_END_BLOCK(); + + fflush(stdout); + fflush(stderr); + + return result == SUCCESS ? 0 : 1; +} -- cgit v1.2.3-70-g09d2