3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function rec($dir, $depth) { $d = dir($dir); if (!$d) return; while ($entry = $d->read()) { if ($entry == '.' || $entry == '..') continue; echo $depth . $entry . "\n"; if (is_dir($dir . '/' . $entry)) { //rec($dir . '/' . $entry, $depth . " "); } } } rec('/opt', '');
based on W4UuM
Output for 5.5.33, 5.6.18 - 5.6.19, 7.0.4, 7.2.0
Warning: dir(/opt): failed to open dir: Permission denied in /in/bfKVZ on line 4
Output for 4.3.0 - 5.5.32, 5.5.34 - 5.6.17, 5.6.20 - 7.0.3, 7.0.5 - 7.1.10