PHP code example of stagerightlabs / phpxdr

1. Go to this page and download the library: Download stagerightlabs/phpxdr library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stagerightlabs / phpxdr example snippets


use StageRightLabs\PhpXdr\XDR;

// Encode
$xdr = XDR::fresh()
    ->write(42, XDR::INT)
    ->write(3.14, XDR::FLOAT)
    ->write('Bad Wolf', XDR::STRING);

$payload = $xdr->asBase64(); // AAAAKkBI9cMAAAAIQmFkIFdvbGY=

// Decode
$xdr = XDR::fromBase64('AAAAKkBI9cMAAAAIQmFkIFdvbGY=');
$int = $xdr->read(XDR::INT); // 42
$float = $xdr->read(XDR::FLOAT); // ~3.14
$string = $xdr->read(XDR::STRING); // 'Bad Wolf'