PHP code example of nixihz / php-object

1. Go to this page and download the library: Download nixihz/php-object 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/ */

    

nixihz / php-object example snippets



class FooBarClass extends PhpObject
{
    /** @var string */
    public $foo;

    /** @var integer */
    public $bar;
}

class DemoClass extends PhpObject
{
    /** @var FooBarClass */
    public $foobar;

    /** @var FooBarClass[] */
    public $foobars;

}

$json = '{"foobar":{"foo":"hello world","bar":64100},"foobars":[{"foo":"hello","bar":641},{"foo":"world","bar":664411}]}';
$demo = (new DemoClass())->fromJson($json);

var_export($demo);