3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public $name; public $age; public $likes; function __construct($name, $age, $likes) { $this->name = $name; $this->age = $age; $this->likes = $likes; } function __get($property) { if (property_exists($this, $property)) { return $this->$property; } else { return "Not available"; } } } $user1 = new Test("Sam", 18, "coding"); $jsonData = json_encode($user1); ?> <form action="process.php" method="get"> <input type="hidden" name="data" value="<?= $jsonData; ?>"> <input type="submit" value="go"> </form>
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
<form action="process.php" method="get"> <input type="hidden" name="data" value="{"name":"Sam","age":18,"likes":"coding"}"> <input type="submit" value="go"> </form>

preferences:
76.09 ms | 1126 KiB | 4 Q