3v4l.org

run code in 500+ 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 = []; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 7
Branch analysis from position: 7
2 jumps found. (Code = 107) Position 1 = 8, Position 2 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rTRoj
function name:  (null)
number of ops:  13
compiled vars:  !0 = $fileList, !1 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CONST                                                'DIRECTORY_PATH', '%2Fvar%2Fwww%2F'
   27     1        INIT_FCALL                                                   'getfiles'
          2        FETCH_CONSTANT                                       ~2      'DIRECTORY_PATH'
          3        SEND_VAL                                                     ~2
          4        DO_FCALL                                          0  $3      
          5        ASSIGN                                                       !0, $3
          6      > JMP                                                          ->12
   28     7  E > > CATCH                                           last         'FileNotFoundException'
   29     8    >   INIT_METHOD_CALL                                             !1, 'getMessage'
          9        DO_FCALL                                          0  $5      
         10        ECHO                                                         $5
   33    11        ASSIGN                                                       !0, <array>
   34    12    > > RETURN                                                       1

Function getfiles:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/rTRoj
function name:  getFiles
number of ops:  9
compiled vars:  !0 = $directory
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
   19     1        NEW                                                  $1      'FileNotFoundException'
          2        ROPE_INIT                                         3  ~3      'Files+in+'
          3        ROPE_ADD                                          1  ~3      ~3, !0
          4        ROPE_END                                          2  ~2      ~3, '+not+founded.'
          5        SEND_VAL_EX                                                  ~2
          6        DO_FCALL                                          0          
          7      > THROW                                             0          $1
   22     8*     > RETURN                                                       null

End of function getfiles

Class FileNotFoundException: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.63 ms | 1865 KiB | 14 Q