Skip to content
Ryan Durham edited this page Nov 27, 2021 · 1 revision

A string is really just a collection of bytes, which makes it very easy to convert to XDR. The methodology for conversion is similar to variable length opaque values. The spec limits strings to 4294967295 bytes in length.

To encode a string:

use StageRightLabs\PhpXdr\XDR;

// Encode
$xdr = XDR::fresh()->write('foobar', XDR::STRING);

To decode a string:

use StageRightLabs\PhpXdr\XDR;
$xdr = XDR::fresh()->write('foobar', XDR::STRING);

// Decode
$string = $xdr->read(XDR::STRING); // 'foobar'
Clone this wiki locally