1. Go to this page and download the library: Download maciej-sz/pj-freeze 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/ */
// WARNING: this is an example of how NOT to encode circular references
use MaciejSz\PjFreeze\PjFreeze;
$data = new \stdClass();
$data->recursion = $data; // circular reference
$raw_encoded = json_encode($data);
echo json_last_error_msg(); // "Recursion detected"
use MaciejSz\PjFreeze\PjFreeze;
$data = new \stdClass();
$data->recursion = $data; // circular reference
$Freeze = new PjFreeze();
$serializedObj = $Freeze->serialize($data)->jsonSerialize();
$jp_freeze_encoded = json_encode($serializedObj);
echo json_last_error_msg(); // "No error"
$unserializedObj = json_decode($jp_freeze_encoded);
$unserialized = $Freeze->unserialize($unserializedObj);
assert($unserialized->recursion === $unserialized);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.