mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
bd9f4fa676
For rationale, see https://github.com/php/php-src/pull/6787 Make extension checks lowercase, add a special case for opcache that has internal name not matching .so filename. Extensions migrated in part 2: * dom * exif * fileinfo * ffi
39 lines
672 B
PHP
39 lines
672 B
PHP
--TEST--
|
|
FFI 008: Array iteration
|
|
--EXTENSIONS--
|
|
ffi
|
|
--INI--
|
|
ffi.enable=1
|
|
--FILE--
|
|
<?php
|
|
$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
|