3v4l.org

run code in 300+ PHP versions simultaneously
<?php $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(php_uname('s'), $c1 == $c2); $c3 = new \Foo\Bar\BUZ(); $c4 = new \Foo\Bar\Buz(); var_dump(php_uname('s'), $c3 == $c4);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Rcf33
function name:  (null)
number of ops:  47
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                                               'sys_get_temp_dir'
          1        DO_ICALL                                         $5      
          2        CONCAT                                           ~6      $5, '%2F'
          3        ASSIGN                                                   !0, ~6
    5     4        INIT_FCALL                                               'file_put_contents'
          5        CONCAT                                           ~8      !0, 'Baz.php'
          6        SEND_VAL                                                 ~8
          7        SEND_VAL                                                 '%3C%3Fphp+namespace+Foo%5CBar%3B+class+Baz+%7B%7D'
          8        DO_ICALL                                                 
    6     9        INIT_FCALL                                               'file_put_contents'
         10        CONCAT                                           ~10     !0, 'Buz.php'
         11        SEND_VAL                                                 ~10
         12        SEND_VAL                                                 '%3C%3Fphp+namespace+Foo%5CBar%3B+class+Buz+%7B%7D'
         13        DO_ICALL                                                 
    8    14        INIT_FCALL                                               'spl_autoload_register'
         15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FRcf33%3A8%240'
   35    16        SEND_VAL                                                 ~12
         17        DO_ICALL                                                 
   37    18        NEW                                              $14     'Foo%5CBar%5CBaz'
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !1, $14
   38    21        NEW                                              $17     'Foo%5CBar%5CBAZ'
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !2, $17
   40    24        INIT_FCALL                                               'var_dump'
         25        INIT_FCALL                                               'php_uname'
         26        SEND_VAL                                                 's'
         27        DO_ICALL                                         $20     
         28        SEND_VAR                                                 $20
         29        IS_EQUAL                                         ~21     !1, !2
         30        SEND_VAL                                                 ~21
         31        DO_ICALL                                                 
   42    32        NEW                                              $23     'Foo%5CBar%5CBUZ'
         33        DO_FCALL                                      0          
         34        ASSIGN                                                   !3, $23
   43    35        NEW                                              $26     'Foo%5CBar%5CBuz'
         36        DO_FCALL                                      0          
         37        ASSIGN                                                   !4, $26
   45    38        INIT_FCALL                                               'var_dump'
         39        INIT_FCALL                                               'php_uname'
         40        SEND_VAL                                                 's'
         41        DO_ICALL                                         $29     
         42        SEND_VAR                                                 $29
         43        IS_EQUAL                                         ~30     !3, !4
         44        SEND_VAL                                                 ~30
         45        DO_ICALL                                                 
         46      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FRcf33%3A8%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/Rcf33
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
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   11     1        ASSIGN                                                   !1, 'Foo%5CBar%5C'
   14     2        BIND_GLOBAL                                              !2, 'base_dir'
   17     3        STRLEN                                           ~7      !1
          4        ASSIGN                                                   !3, ~7
   18     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
   20    12    > > RETURN                                                   null
   24    13    >   INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                         $11     
         17        ASSIGN                                                   !4, $11
   29    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
   32    26        INIT_FCALL                                               'file_exists'
         27        SEND_VAR                                                 !5
         28        DO_ICALL                                         $17     
         29      > JMPZ                                                     $17, ->31
   33    30    >   INCLUDE_OR_EVAL                                          !5, REQUIRE
   35    31    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FRcf33%3A8%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.8 ms | 1400 KiB | 31 Q