PHP code example of loner / dataset
1. Go to this page and download the library: Download loner/dataset 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/ */
loner / dataset example snippets
#!/usr/bin/env php
declare(strict_types=1);
namespace Loner\App;
use Loner\Dataset\{Dataset, DatasetInterface};
// composer 自加载
{
return [
'x' => 'x',
'y' => 'y',
'z' => 'z'
];
}
}
// 创建数据对象,含有默认的属性:x、y、z
$data = new Data();
// 数据受保护,移除失败
unset($data->x);
// 类型一致,修改成功
$data->y = 'yy';
// 类型不同,修改失败
$data->z = 123;
var_dump($data->x, $data->y, $data->z); // "x"、"yy"、"z"
// 其它属性操作,与对象常规属性操作一致
$data->n = 'n';
$data->m = 'm';
unset($data->m);
var_dump($data->n, $data->m); // "n"、NULL