3v4l.org

run code in 200+ PHP versions simultaneously
<?php class JsonSerializer { public static function serialize($value) { var_dump($value); } public function __call($method, $args) { if ('serialize' !== strtolower($method)) { throw new \BadMethodCallException('Call to undefined method '.__CLASS__."::$method()"); } return self::serialize(...$args); } } JsonSerializer::serialize('foo'); (new JsonSerializer())->serialize('bar');
based on 7cp1C
Output for 7.0.0 - 7.4.0
string(3) "foo" string(3) "bar"