xref: /PHP-8.1/ext/ffi/tests/025.phpt (revision bd9f4fa6)
1--TEST--
2FFI 025: direct work with primitive types
3--EXTENSIONS--
4ffi
5--INI--
6ffi.enable=1
7--FILE--
8<?php
9    $x = FFI::new("int");
10    $x->cdata = 5;
11    var_dump($x);
12    $x->cdata += 2;
13    var_dump($x);
14    echo "$x\n\n";
15    unset($x);
16
17    $x = FFI::new("char");
18    $x->cdata = 'a';
19    var_dump($x);
20    $x->cdata++;
21    var_dump($x);
22    echo "$x\n\n";
23    unset($x);
24?>
25--EXPECTF--
26object(FFI\CData:int32_t)#%d (1) {
27  ["cdata"]=>
28  int(5)
29}
30object(FFI\CData:int32_t)#%d (1) {
31  ["cdata"]=>
32  int(7)
33}
347
35
36object(FFI\CData:char)#%d (1) {
37  ["cdata"]=>
38  string(1) "a"
39}
40object(FFI\CData:char)#%d (1) {
41  ["cdata"]=>
42  string(1) "b"
43}
44b
45