3v4l.org

run code in 300+ PHP versions simultaneously
<?php function shouldFileBeHiddenA(string $file): bool { static $knownHiddenFiles = ['.access', '.', '.htaccess']; if(in_array($file, $knownHiddenFiles)) { return true; } if(str_ends_with($file, '.php')) { return true; } return false; } function shouldFileBeHiddenB(string $file): bool { static $knownHiddenFiles = ['.access', '.', '.htaccess']; static $knownHiddenExtensions = ['php']; if(in_array($file, $knownHiddenFiles)) { return true; } if(in_array(pathinfo($file, PATHINFO_EXTENSION), $knownHiddenExtensions)) { return true; } return false; } var_dump(shouldFileBeHiddenA('.htaccess')); var_dump(shouldFileBeHiddenA('test.php')); var_dump(shouldFileBeHiddenA('test.html')); var_dump(shouldFileBeHiddenB('.htaccess')); var_dump(shouldFileBeHiddenB('test.php')); var_dump(shouldFileBeHiddenB('test.html'));

preferences:
97.53 ms | 407 KiB | 5 Q