Type ‣ Null ᴾᴴᴾ - chung-leong/zigar GitHub Wiki
JavaScript | PHP
The literal null in Zig is represented as null in PHP. You will only encounter it if
you explicitly export null.
pub const Null = null;
<?php
$m = zigar_use(__DIR__ . '/null-example-1.zig');
debug_zval_dump($m->null_value);
NULL
As @TypeOf(null) is a comptime type, you can only put it into a struct if you
make it a comptime field:
pub const NumberAndNothing = struct {
number: i32,
comptime nothing: @TypeOf(null) = null,
};
<?php
$m = zigar_use(__DIR__ . '/null-example-2.zig');
$struct = new $m->NumberAndNothing(number: 1234);
print_r($struct);
NumberAndNothing Object
(
[number] => 1234
[nothing] =>
)