3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Cookie{ public $username; public $coffee; public $token; public function __toString() { return "<p> Hey ".$this->username."! </p><br>" . "<p> Here is your token for a free ". $this->coffee."!!</p><p>".$this->token."</p><p>Give us this token at your next visit!</p>"; } } class Token{ public $coffee; public $username; public function __construct($coffee, $username){ $this->coffee = (string)$coffee; $this->username = (string)$username; $this->crypto = "crc32"; } public function __toString(){ $x = $this->crypto; return substr(md5(rand($x($this->coffee . $this->username), 0xc0ffee)), 10); } } $a = new Token("a","b"); $a->crypto = "c"; var_dump(serialize($a));
Output for 5.6.38 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.26, 7.3.0 - 7.3.13, 7.4.0 - 7.4.1
string(81) "O:5:"Token":3:{s:6:"coffee";s:1:"a";s:8:"username";s:1:"b";s:6:"crypto";s:1:"c";}"

preferences:
103.97 ms | 402 KiB | 119 Q