From 7e9c65507f2ba51ff7c13cfc18cf29722b89c973 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 2 Oct 2023 01:27:55 +0900 Subject: commit files --- php-wasm.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 php-wasm.c (limited to 'php-wasm.c') diff --git a/php-wasm.c b/php-wasm.c new file mode 100644 index 0000000..cef661f --- /dev/null +++ b/php-wasm.c @@ -0,0 +1,24 @@ +#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(); + + fprintf(stdout, "\n"); + fflush(stdout); + fprintf(stderr, "\n"); + fflush(stderr); + + return result == SUCCESS ? 0 : 1; +} -- cgit v1.2.3-70-g09d2