3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(php_uname('s')); $base_dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR; file_put_contents($base_dir . 'Baz.php', "<?php namespace Foo\Bar; class Baz {}"); file_put_contents($base_dir . 'Buz.php', "<?php namespace Foo\Bar; class Buz {}"); spl_autoload_register(function ($class) { // project-specific namespace prefix $prefix = 'Foo\\Bar\\'; // base directory for the namespace prefix global $base_dir; # = __DIR__ . '/src/'; // does the class use the namespace prefix? $len = strlen($prefix); if (strncmp($prefix, $class, $len) !== 0) { // no, move to the next registered autoloader return; } // get the relative class name $relative_class = substr($class, $len); // replace the namespace prefix with the base directory, replace namespace // separators with directory separators in the relative class name, append // with .php $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; // if the file exists, require it if (file_exists($file)) { require $file; } }); $c1 = new \Foo\Bar\Baz(); $c2 = new \Foo\Bar\BAZ(); var_dump($c1 == $c2); $c3 = new \Foo\Bar\BUZ(); $c4 = new \Foo\Bar\Buz(); var_dump($c3 == $c4);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8RYr2
function name:  (null)
number of ops:  45
compiled vars:  !0 = $base_dir, !1 = $c1, !2 = $c2, !3 = $c3, !4 = $c4
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'php_uname'
          2        SEND_VAL                                                 's'
          3        DO_ICALL                                         $5      
          4        SEND_VAR                                                 $5
          5        DO_ICALL                                                 
    5     6        INIT_FCALL                                               'sys_get_temp_dir'
          7        DO_ICALL                                         $7      
          8        CONCAT                                           ~8      $7, '%2F'
          9        ASSIGN                                                   !0, ~8
    7    10        INIT_FCALL                                               'file_put_contents'
         11        CONCAT                                           ~10     !0, 'Baz.php'
         12        SEND_VAL                                                 ~10
         13        SEND_VAL                                                 '%3C%3Fphp+namespace+Foo%5CBar%3B+class+Baz+%7B%7D'
         14        DO_ICALL                                                 
    8    15        INIT_FCALL                                               'file_put_contents'
         16        CONCAT                                           ~12     !0, 'Buz.php'
         17        SEND_VAL                                                 ~12
         18        SEND_VAL                                                 '%3C%3Fphp+namespace+Foo%5CBar%3B+class+Buz+%7B%7D'
         19        DO_ICALL                                                 
   10    20        INIT_FCALL                                               'spl_autoload_register'
         21        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8RYr2%3A10%240'
   37    22        SEND_VAL                                                 ~14
         23        DO_ICALL                                                 
   39    24        NEW                                              $16     'Foo%5CBar%5CBaz'
         25        DO_FCALL                                      0          
         26        ASSIGN                                                   !1, $16
   40    27        NEW                                              $19     'Foo%5CBar%5CBAZ'
         28        DO_FCALL                                      0          
         29        ASSIGN                                                   !2, $19
   42    30        INIT_FCALL                                               'var_dump'
         31        IS_EQUAL                                         ~22     !1, !2
         32        SEND_VAL                                                 ~22
         33        DO_ICALL                                                 
   44    34        NEW                                              $24     'Foo%5CBar%5CBUZ'
         35        DO_FCALL                                      0          
         36        ASSIGN                                                   !3, $24
   45    37        NEW                                              $27     'Foo%5CBar%5CBuz'
         38        DO_FCALL                                      0          
         39        ASSIGN                                                   !4, $27
   47    40        INIT_FCALL                                               'var_dump'
         41        IS_EQUAL                                         ~30     !3, !4
         42        SEND_VAL                                                 ~30
         43        DO_ICALL                                                 
         44      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F8RYr2%3A10%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 31
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/8RYr2
function name:  {closure}
number of ops:  32
compiled vars:  !0 = $class, !1 = $prefix, !2 = $base_dir, !3 = $len, !4 = $relative_class, !5 = $file
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   13     1        ASSIGN                                                   !1, 'Foo%5CBar%5C'
   16     2        BIND_GLOBAL                                              !2, 'base_dir'
   19     3        STRLEN                                           ~7      !1
          4        ASSIGN                                                   !3, ~7
   20     5        INIT_FCALL                                               'strncmp'
          6        SEND_VAR                                                 !1
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !3
          9        DO_ICALL                                         $9      
         10        IS_NOT_IDENTICAL                                         $9, 0
         11      > JMPZ                                                     ~10, ->13
   22    12    > > RETURN                                                   null
   26    13    >   INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                         $11     
         17        ASSIGN                                                   !4, $11
   31    18        INIT_FCALL                                               'str_replace'
         19        SEND_VAL                                                 '%5C'
         20        SEND_VAL                                                 '%2F'
         21        SEND_VAR                                                 !4
         22        DO_ICALL                                         $13     
         23        CONCAT                                           ~14     !2, $13
         24        CONCAT                                           ~15     ~14, '.php'
         25        ASSIGN                                                   !5, ~15
   34    26        INIT_FCALL                                               'file_exists'
         27        SEND_VAR                                                 !5
         28        DO_ICALL                                         $17     
         29      > JMPZ                                                     $17, ->31
   35    30    >   INCLUDE_OR_EVAL                                          !5, REQUIRE
   37    31    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8RYr2%3A10%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.76 ms | 1400 KiB | 31 Q