我正在使用这个 PHP 代码来创建带有默认单变量的 PHP 类。但这并不完美。
Note
:我需要将数据存储在单个变量中。
<?PHP
class hello
{
public $data;
}
$test = new hello();
$test->data->user1->name = "Charan";
$test->data->user1->sex = "male";
$test->data->user1->age = "25";
$test->data->user2->name = "Kajal";
$test->data->user2->sex = "female";
$test->data->user2->age = "21";
print_r($test->data->user1);
?>
我收到了这个错误:
请帮助我,如何解决?