PHP code example of porkchopsandwiches / preserialiser
1. Go to this page and download the library: Download porkchopsandwiches/preserialiser 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/ */
porkchopsandwiches / preserialiser example snippets
use PorkChopSandwiches\Preserialiser\Preserialiser;
use PorkChopSandwiches\Preserialiser\Preserialisable;
class ExampleB implements Preserialisable {
private $a = "foo";
private $b = "bar";
public function preserialise (array $args = array()) {
$data = array(
"a" => $this -> a
);
if (array_key_exists("
use PorkChopSandwiches\Preserialiser\Preserialiser;
use PorkChopSandwiches\Preserialiser\Preserialisable;
class ExampleParent implements Preserialisable {
private $children = array();
public function addChild(ExampleChild $child) {
$child -> setParent($this);
$this -> children[] = $child;
}
public function preserialise (array $args = array()) {
$data = array(
"type" => "parent"
);
if (array_key_exists(""] = $this -> parent;
}
return $data;
}
}
$p = new Preserialiser();
$parent = new ExampleParent();
$child = new ExampleChild();
$parent -> addChild($child);
$p -> preserialise($parent);
# => array("type" => "parent")
$p -> preserialise($parent, array("
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.