1. Go to this page and download the library: Download componenta/var-export 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/ */
namespace Componenta\VarExport;
interface VarExportInterface
{
public function export(mixed $var): ?string;
}
interface VarExportAwareInterface
{
public function withVarExport(VarExport $varExport): static;
}
final class VarExport
{
public function __construct(VarExportInterface ...$exporters);
public static function withDefaults(): self;
public function export(mixed $var): string;
}
use Componenta\VarExport\ArrayExporter;
use Componenta\VarExport\ClosureExporter;
use Componenta\VarExport\EnumExporter;
use Componenta\VarExport\ScalarExporter;
use Componenta\VarExport\VarExport;
$exporter = new VarExport(
new ConfigValueExporter(),
new ScalarExporter(),
new ArrayExporter(),
new EnumExporter(),
new ClosureExporter(),
);
$arrayExporter = (new ArrayExporter())
->withVarExport(VarExport::withDefaults());
$expression = $arrayExporter->export(['answer' => 42]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.