Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
class A {
protected \stdClass $x;
public function __construct()
{
$this->reset();
}
public function getX()
{
return $this->x;
}
public function reset()
{
$this->x = new stdClass();
$this->x->random = rand(0, 1000);
}
}
$a = new A();
$test = $a->getX();
echo spl_object_id($test) . "\n";
$a->reset();
echo spl_object_id($test) . "\n";
$test = $a->getX();
echo spl_object_id($test) . "\n";