3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Tester { private $code = 0; static private $instance; private function __construct() { } static public function getInstance() { if (!RUN_WWW) { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; } else { return null; } } private $errors = array(); public function addError($txt, $code = 1) { $this->errors[] = ['txt' => $txt, 'code' => $code, 'tm' => date('Y-m-d H:i:s')]; if ($this->code === 0) { $this->code = $code; } } public function countErrors() { return count($this->errors); } public function valid() { return empty($this->errors) ? '0' : ($this->code != 0 ? $this->code : '999'); } public function showErrors() { return print_r($this->errors,1); } public function __toString() { return $this->showErrors(); } } $tester = Tester::getInstance(); $s = serialize($tester); $d = deserialize($s); var_dump($d);
Output for 7.2.0
Warning: Use of undefined constant RUN_WWW - assumed 'RUN_WWW' (this will throw an Error in a future version of PHP) in /in/p3qvk on line 17 Fatal error: Uncaught Error: Call to undefined function deserialize() in /in/p3qvk:63 Stack trace: #0 {main} thrown in /in/p3qvk on line 63
Process exited with code 255.
Output for 7.0.0 - 7.1.10
Notice: Use of undefined constant RUN_WWW - assumed 'RUN_WWW' in /in/p3qvk on line 17 Fatal error: Uncaught Error: Call to undefined function deserialize() in /in/p3qvk:63 Stack trace: #0 {main} thrown in /in/p3qvk on line 63
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Notice: Use of undefined constant RUN_WWW - assumed 'RUN_WWW' in /in/p3qvk on line 17 Fatal error: Call to undefined function deserialize() in /in/p3qvk on line 63
Process exited with code 255.