PHP code example of andytruong / serializer
1. Go to this page and download the library: Download andytruong/serializer 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/ */
andytruong / serializer example snippets
class Person {
private $name;
public function getName() { return $this->name; }
public function setName($name) { $this->name = $name; }
}
$person = new Person();
$person->setName('Johnson American');
(new AndyTruong\Serializer\Serializer())
->toArray($person); // ['name' => 'Johnson American']
$person = (new AndyTruong\Serializer\Unserializer())
->fromArray(['name' => 'Johnson America']);