Download src/php/php-src/ext/ffi/tests/200.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 849 Bytes
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/ffi/tests/200.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/ext/ffi/tests/200.phpt
-
curl -L -o 200.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/ffi/tests/200.phpt
849 Bytes
| --TEST-- | |
| FFI 200: PHP callbacks | |
| --EXTENSIONS-- | |
| ffi | |
| --SKIPIF-- | |
| require_once('utils.inc'); | |
| try { | |
| FFI::cdef("void* zend_write;"); | |
| } catch (Throwable $e) { | |
| die('skip PHP symbols not available'); | |
| } | |
| --INI-- | |
| ffi.enable=1 | |
| opcache.jit=0 | |
| --FILE-- | |
| require_once('utils.inc'); | |
| $zend = FFI::cdef(" | |
| typedef size_t (*zend_write_func_t)(const char *str, size_t str_length); | |
| extern zend_write_func_t zend_write; | |
| "); | |
| echo "Hello World!\n"; | |
| $orig_zend_write = clone $zend->zend_write; | |
| $zend->zend_write = function($str, $len) { | |
| global $orig_zend_write; | |
| $orig_zend_write("{\n\t", 3); | |
| $ret = $orig_zend_write($str, $len); | |
| $orig_zend_write("}\n", 2); | |
| return $ret; | |
| }; | |
| echo "Hello World!\n"; | |
| $zend->zend_write = $orig_zend_write; | |
| echo "Hello World!\n"; | |
| --EXPECT-- | |
| Hello World! | |
| { | |
| Hello World! | |
| } | |
| Hello World! | |