PHP code example of fas / exportable

1. Go to this page and download the library: Download fas/exportable 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/ */

    

fas / exportable example snippets




as\Exportable\Exporter;

$exporter = new Exporter();

$data = [
    'somefunc' => static function () {
        return 'test';
    }
];

$output = $exporter->export($data);

print "$output\n";



as\Exportable\ExportableInterface;
use Fas\Exportable\Exporter;

class UpperCase implements ExportableInterface
{
    private string $str;

    public function __construct(string $str)
    {
        $this->str = $str;
    }

    public function exportable(Exporter $exporter, $level = 0): string
    {
        return var_export(strtoupper($this->str), true);
    }
}

$exporter = new Exporter();

$data = [
    'somekey' => new UpperCase('somevalue'),
];

$output = $exporter->export($data);

print "$output\n";

[
  'somefunc' => static function () {
        return 'test';
    }
]