Download src/php/php-src/ext/ffi/tests/008.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 695 Bytes
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/ffi/tests/008.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/ext/ffi/tests/008.phpt
-
curl -L -o 008.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/ext/ffi/tests/008.phpt
695 Bytes
| --TEST-- | |
| FFI 008: Array iteration | |
| --EXTENSIONS-- | |
| ffi | |
| --INI-- | |
| ffi.enable=1 | |
| --FILE-- | |
| $ffi = FFI::cdef(); | |
| $a = $ffi->new("int[3]"); | |
| $a[1] = 10; | |
| $a[2] = 20; | |
| var_dump(count($a)); | |
| foreach ($a as $key => $val) { | |
| echo "$key => $val\n"; | |
| } | |
| $a = $ffi->new("struct {int x,y;}"); | |
| try { | |
| var_dump(count($a)); | |
| } catch (Throwable $e) { | |
| echo get_class($e) . ": " . $e->getMessage()."\n"; | |
| } | |
| try { | |
| foreach ($a as $key => $val) { | |
| echo "$key => $val\n"; | |
| } | |
| } catch (Throwable $e) { | |
| echo get_class($e) . ": " . $e->getMessage()."\n"; | |
| } | |
| --EXPECT-- | |
| int(3) | |
| 0 => 0 | |
| 1 => 10 | |
| 2 => 20 | |
| FFI\Exception: Attempt to count() on non C array | |
| FFI\Exception: Attempt to iterate on non C array | |