PHP code example of alexkratky / variable-to-json
1. Go to this page and download the library: Download alexkratky/variable-to-json 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/ */
alexkratky / variable-to-json example snippets
use AlexKratky\VariableToJson;
$x = new TestClass(); // test class
$x->load();
$x->load2();
$x->load3();
file_put_contents("output.json", VariableToJson::convert($x, true));
file_put_contents("output2.json", VariableToJson::convert([
'test' => 1
], true));
file_put_contents("output3.json", VariableToJson::convert(function(string $text ="xx") {
echo $text;
}, true));