erlang term format
v0.1.2
ตัวถอดรหัส PHP และตัวเข้ารหัสสำหรับรูปแบบคำศัพท์ ERLANG
โดยค่าเริ่มต้น encoder เข้ารหัสสตริงตัวเลขเป็น 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