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