3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function getTopNews($number = 5,$reset =false) { static $cache = false; //cache reset if ($reset) $cache = false; //cache get if ($cache){ echo 'cache '; return $cache; } else { echo 'query '; /*$res = db_query("SELECT id,header,content FROM `news` ORDER BY id DESC LIMIT %d",(int)$number); while($row = db_fetch_array($res)){ $out[] = $row; } */ $out ='db'; //cache set $cache = $out; } return $out; } getTopNews(); echo '<hr>'; getTopNews();
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
query <hr>cache