erlang term format
v0.1.2
Dekoder dan enkoder PHP untuk format istilah Erlang.
Secara default, encoder mengkodekan string numerik sebagai BigInt. Perilaku ini dapat diubah dengan lulus Encoder::ENCODE_DIRECT_STRINGS_AS_BINARY ke konstruktor, jadi semua string yang langsung diberikan ke Encoder->encode akan dikodekan sebagai string. Atau untuk selalu menyandikan string numerik sebagai biner, lulus Encoder::ENCODE_STRINGS_AS_BINARY ke konstruktor.
Instal perpustakaan ini melalui komposer menggunakan
composer require obsidian/etf
Contoh decoding minimal:
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)
}
*/Contoh Pengkodean Minimal:
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