Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?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";
Copy Clear