3v4l.org

run code in 300+ PHP versions simultaneously
<?php const DIRECTORY_PATH = '/var/www/'; class FileNotFoundException extends \Exception { } function getFiles(string $directory) { // trying getting files /** *if (isFile($directory)) { * throw new \Exception("First argument of getFiles must be a directory, not a file."); *} */ throw new FileNotFoundException("Files in $directory not founded."); // или может быть, тебе не сильно важно, найдет ли он файлы, можешь возвращать пустой массив // кучу вариантов короче) } // smth... try { $fileList = getFiles(DIRECTORY_PATH); } catch (FileNotFoundException $e) { echo $e->getMessage(); // обрабатывай в зависимости от того, что тебе нужно =) // можешь присвоить пустой массив $fileList = []; }
Output for git.master, git.master_jit, rfc.property-hooks
Files in /var/www/ not founded.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
28.06 ms | 405 KiB | 5 Q