3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Cachable { public function getCacheTtl(): int; } abstract class AbstractCacheItem implements Cachable { private $config = []; public function getCacheTtl(): int { return $this->config['cache_ttl'] ?? defined('static::CACHE_TTL') ? constant('static::CACHE_TTL') : 60; } } class SomeCacheItemA extends AbstractCacheItem { public const CACHE_TTL = 61; } class SomeCacheItemB extends AbstractCacheItem { } $a = new SomeCacheItemA(); $b = new SomeCacheItemB(); var_dump($a->getCacheTtl(), $b->getCacheTtl());

preferences:
54.32 ms | 402 KiB | 5 Q