erlang term format
v0.1.2
PHP解碼器和ERLANG項格式的編碼器。
默認情況下,編碼器將數字字符串編碼為bigint。可以通過將Encoder::ENCODE_DIRECT_STRINGS_AS_BINARY傳遞給構造函數來更改此行為,因此直接給出的Encoder->encode所有字符串都將被編碼為字符串。或始終將數字字符串編碼為二進制,將Encoder::ENCODE_STRINGS_AS_BINARY傳遞給構造函數。
使用作曲家安裝此庫
composer require obsidian/etf
最小解碼示例:
use Obsidian ETF Decoder ;
// the binary erlang term format string (#PID<0.81.0>)
$ binary = base64_decode ( " g2d3DW5vbm9kZUBub2hvc3QAAABRAAAAAAA= " );
$ etf = new Decoder ();
$ pid = $ etf -> decode ( $ binary );
var_dump ( $ pid );
/*
class ObsidianETFPID#6 (4) {
public $node =>
class ObsidianETFAtom#5 (1) {
public $atom =>
string(13) "nonode@nohost"
}
public $id =>
int(81)
public $serial =>
int(0)
public $creation =>
int(0)
}
*/最小編碼示例:
use Obsidian ETF Atom ;
use Obsidian ETF Encoder ;
$ value = new Atom ( ' hello ' );
$ etf = new Encoder ();
$ binary = $ etf -> encode ( $ value );
var_dump ( $ binary );
/*
string(8) "w║hello"
*/http://erlang.org/doc/apps/erts/erl_ext_dist.html