Special property ‣ __base64 ᴾᴴᴾ - chung-leong/zigar GitHub Wiki
JavaScript | PHP
A base64 string containing the object's underlying bytes. Can be used to embed the content of a struct into a URL. Example:
pub const Hello = struct {
number1: i32 = 0,
number2: i32 = 0,
number3: i32 = 0,
};
<?php
$m = zigar_use(__DIR__ . '/base64-example-1.zig');
$hello = new $m->Hello(number1: 1000, number2: 2000);
$url = "http://example.net/?s={$hello->__base64}";
$parts = parse_url($url);
parse_str($parts['query'], $variables);
$hello_copy = new $m->Hello(__base64: $variables['s']);
print_r($hello);
print_r($hello_copy);
Hello Object
(
[number1] => 1000
[number2] => 2000
[number3] => 0
)
Hello Object
(
[number1] => 1000
[number2] => 2000
[number3] => 0
)