3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Cache { private static $URL_CACHE; public function cacheUrl($url, $entityId) { echo '<br>caching '.$url.' as '.$entityId . '<br />'; self::$URL_CACHE[$url]=$entityId; echo '<br>Cache content:<br>'; foreach (self::$URL_CACHE as $key => $value) { echo 'Key: '.$key.' Value: '.$value.'<br />'; } } } $cache = new Cache(); $cache->cacheUrl('uri1', 'ent1'); $ya_cache = new Cache(); $ya_cache->cacheUrl('uri2', 'ent2');
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<br>caching uri1 as ent1<br /><br>Cache content:<br>Key: uri1 Value: ent1<br /><br>caching uri2 as ent2<br /><br>Cache content:<br>Key: uri1 Value: ent1<br />Key: uri2 Value: ent2<br />

preferences:
226.67 ms | 404 KiB | 300 Q