3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = (object) array(); $b = (object) array(); function object_handle($obj) { static $mask = 0, $offset; if (!$mask) { if (defined('HHVM_VERSION')) { $offset = 24; } else { $offset = 8; } $o = (object) array(); $mask = hexdec(substr(spl_object_hash($o), $offset, 8)); // check if we are nested in an output buffering handler to prevent a fatal error with ob_start() below foreach (debug_backtrace(PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS : false) as $frame) { if (isset($frame['function'][0]) && !isset($frame['class']) && 'o' === $frame['function'][0] && in_array($frame['function'], array('ob_clean', 'ob_end_clean', 'ob_flush', 'ob_end_flush', 'ob_get_contents', 'ob_get_flush')) ) { $frame['line'] = 0; break; } } if (!empty($frame['line'])) { debug_zval_dump($o); ob_start(); debug_zval_dump($o); $mask ^= substr(ob_get_clean(), 17); } } return hexdec(substr(spl_object_hash($obj), $offset, 8)) ^ $mask; } //ob_start('abc'); //ob_end_flush(); $o = array(); echo object_handle($o[]=(object) array()), "\n"; echo object_handle($o[]=(object) array()), "\n"; echo object_handle($o[]=(object) array()), "\n"; echo object_handle($o[]=(object) array()), "\n"; echo object_handle($o[]=(object) array()), "\n"; echo object_handle($o[]=(object) array()), "\n"; echo object_handle($o[]=(object) array()), "\n"; echo object_handle($b), "\n"; echo object_handle($a), "\n"; function abc() { global $a; isset($a) or $a = (object) array(); return object_handle($a); } ob_start('abc');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v0Xvl
function name:  (null)
number of ops:  75
compiled vars:  !0 = $a, !1 = $b, !2 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   CAST                                          8  ~3      <array>
          1        ASSIGN                                                   !0, ~3
    4     2        CAST                                          8  ~5      <array>
          3        ASSIGN                                                   !1, ~5
   42     4        ASSIGN                                                   !2, <array>
   43     5        INIT_FCALL                                               'object_handle'
          6        CAST                                          8  ~9      <array>
          7        ASSIGN_DIM                                       ~8      !2
          8        OP_DATA                                                  ~9
          9        SEND_VAL                                                 ~8
         10        DO_FCALL                                      0  $10     
         11        ECHO                                                     $10
         12        ECHO                                                     '%0A'
   44    13        INIT_FCALL                                               'object_handle'
         14        CAST                                          8  ~12     <array>
         15        ASSIGN_DIM                                       ~11     !2
         16        OP_DATA                                                  ~12
         17        SEND_VAL                                                 ~11
         18        DO_FCALL                                      0  $13     
         19        ECHO                                                     $13
         20        ECHO                                                     '%0A'
   45    21        INIT_FCALL                                               'object_handle'
         22        CAST                                          8  ~15     <array>
         23        ASSIGN_DIM                                       ~14     !2
         24        OP_DATA                                                  ~15
         25        SEND_VAL                                                 ~14
         26        DO_FCALL                                      0  $16     
         27        ECHO                                                     $16
         28        ECHO                                                     '%0A'
   46    29        INIT_FCALL                                               'object_handle'
         30        CAST                                          8  ~18     <array>
         31        ASSIGN_DIM                                       ~17     !2
         32        OP_DATA                                                  ~18
         33        SEND_VAL                                                 ~17
         34        DO_FCALL                                      0  $19     
         35        ECHO                                                     $19
         36        ECHO                                                     '%0A'
   47    37        INIT_FCALL                                               'object_handle'
         38        CAST                                          8  ~21     <array>
         39        ASSIGN_DIM                                       ~20     !2
         40        OP_DATA                                                  ~21
         41        SEND_VAL                                                 ~20
         42        DO_FCALL                                      0  $22     
         43        ECHO                                                     $22
         44        ECHO                                                     '%0A'
   48    45        INIT_FCALL                                               'object_handle'
         46        CAST                                          8  ~24     <array>
         47        ASSIGN_DIM                                       ~23     !2
         48        OP_DATA                                                  ~24
         49        SEND_VAL                                                 ~23
         50        DO_FCALL                                      0  $25     
         51        ECHO                                                     $25
         52        ECHO                                                     '%0A'
   49    53        INIT_FCALL                                               'object_handle'
         54        CAST                                          8  ~27     <array>
         55        ASSIGN_DIM                                       ~26     !2
         56        OP_DATA                                                  ~27
         57        SEND_VAL                                                 ~26
         58        DO_FCALL                                      0  $28     
         59        ECHO                                                     $28
         60        ECHO                                                     '%0A'
   50    61        INIT_FCALL                                               'object_handle'
         62        SEND_VAR                                                 !1
         63        DO_FCALL                                      0  $29     
         64        ECHO                                                     $29
         65        ECHO                                                     '%0A'
   51    66        INIT_FCALL                                               'object_handle'
         67        SEND_VAR                                                 !0
         68        DO_FCALL                                      0  $30     
         69        ECHO                                                     $30
         70        ECHO                                                     '%0A'
   61    71        INIT_FCALL                                               'ob_start'
         72        SEND_VAL                                                 'abc'
         73        DO_ICALL                                                 
         74      > RETURN                                                   1

Function object_handle:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 72
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 77) Position 1 = 32, Position 2 = 53
Branch analysis from position: 32
2 jumps found. (Code = 78) Position 1 = 33, Position 2 = 53
Branch analysis from position: 33
2 jumps found. (Code = 46) Position 1 = 36, Position 2 = 39
Branch analysis from position: 36
2 jumps found. (Code = 46) Position 1 = 40, Position 2 = 44
Branch analysis from position: 40
2 jumps found. (Code = 46) Position 1 = 45, Position 2 = 48
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 52
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 72
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 72
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 48
Branch analysis from position: 44
Branch analysis from position: 39
Branch analysis from position: 53
Branch analysis from position: 53
Branch analysis from position: 28
2 jumps found. (Code = 77) Position 1 = 32, Position 2 = 53
Branch analysis from position: 32
Branch analysis from position: 53
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
Branch analysis from position: 28
Branch analysis from position: 72
filename:       /in/v0Xvl
function name:  object_handle
number of ops:  86
compiled vars:  !0 = $obj, !1 = $mask, !2 = $offset, !3 = $o, !4 = $frame
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   10     3        BOOL_NOT                                         ~5      !1
          4      > JMPZ                                                     ~5, ->72
   11     5    >   DEFINED                                                  'HHVM_VERSION'
          6      > JMPZ                                                     ~6, ->9
   12     7    >   ASSIGN                                                   !2, 24
          8      > JMP                                                      ->10
   14     9    >   ASSIGN                                                   !2, 8
   16    10    >   CAST                                          8  ~9      <array>
         11        ASSIGN                                                   !3, ~9
   17    12        INIT_FCALL                                               'hexdec'
         13        INIT_FCALL                                               'substr'
         14        INIT_FCALL                                               'spl_object_hash'
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                         $11     
         17        SEND_VAR                                                 $11
         18        SEND_VAR                                                 !2
         19        SEND_VAL                                                 8
         20        DO_ICALL                                         $12     
         21        SEND_VAR                                                 $12
         22        DO_ICALL                                         $13     
         23        ASSIGN                                                   !1, $13
   20    24        INIT_FCALL                                               'debug_backtrace'
         25      > JMPZ                                                     <true>, ->28
         26    >   QM_ASSIGN                                        ~15     2
         27      > JMP                                                      ->29
         28    >   QM_ASSIGN                                        ~15     <false>
         29    >   SEND_VAL                                                 ~15
         30        DO_ICALL                                         $16     
         31      > FE_RESET_R                                       $17     $16, ->53
         32    > > FE_FETCH_R                                               $17, !4, ->53
   21    33    >   FETCH_DIM_IS                                     ~18     !4, 'function'
         34        ISSET_ISEMPTY_DIM_OBJ                         0  ~19     ~18, 0
         35      > JMPZ_EX                                          ~19     ~19, ->39
         36    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~20     !4, 'class'
         37        BOOL_NOT                                         ~21     ~20
         38        BOOL                                             ~19     ~21
         39    > > JMPZ_EX                                          ~19     ~19, ->44
         40    >   FETCH_DIM_R                                      ~22     !4, 'function'
         41        FETCH_DIM_R                                      ~23     ~22, 0
         42        IS_IDENTICAL                                     ~24     ~23, 'o'
         43        BOOL                                             ~19     ~24
         44    > > JMPZ_EX                                          ~19     ~19, ->48
   22    45    >   FETCH_DIM_R                                      ~25     !4, 'function'
         46        IN_ARRAY                                         ~26     ~25, <array>
         47        BOOL                                             ~19     ~26
         48    > > JMPZ                                                     ~19, ->52
   24    49    >   ASSIGN_DIM                                               !4, 'line'
         50        OP_DATA                                                  0
   25    51      > JMP                                                      ->53
   20    52    > > JMP                                                      ->32
         53    >   FE_FREE                                                  $17
   28    54        ISSET_ISEMPTY_DIM_OBJ                         1  ~28     !4, 'line'
         55        BOOL_NOT                                         ~29     ~28
         56      > JMPZ                                                     ~29, ->72
   29    57    >   INIT_FCALL                                               'debug_zval_dump'
         58        SEND_VAR                                                 !3
         59        DO_ICALL                                                 
   30    60        INIT_FCALL                                               'ob_start'
         61        DO_ICALL                                                 
   31    62        INIT_FCALL                                               'debug_zval_dump'
         63        SEND_VAR                                                 !3
         64        DO_ICALL                                                 
   32    65        INIT_FCALL                                               'substr'
         66        INIT_FCALL                                               'ob_get_clean'
         67        DO_ICALL                                         $33     
         68        SEND_VAR                                                 $33
         69        SEND_VAL                                                 17
         70        DO_ICALL                                         $34     
         71        ASSIGN_OP                                    11          !1, $34
   36    72    >   INIT_FCALL                                               'hexdec'
         73        INIT_FCALL                                               'substr'
         74        INIT_FCALL                                               'spl_object_hash'
         75        SEND_VAR                                                 !0
         76        DO_ICALL                                         $36     
         77        SEND_VAR                                                 $36
         78        SEND_VAR                                                 !2
         79        SEND_VAL                                                 8
         80        DO_ICALL                                         $37     
         81        SEND_VAR                                                 $37
         82        DO_ICALL                                         $38     
         83        BW_XOR                                           ~39     !1, $38
         84      > RETURN                                                   ~39
   37    85*     > RETURN                                                   null

End of function object_handle

Function abc:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/v0Xvl
function name:  abc
number of ops:  11
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   BIND_GLOBAL                                              !0, 'a'
   56     1        ISSET_ISEMPTY_CV                                 ~1      !0
          2      > JMPNZ_EX                                         ~1      ~1, ->6
          3    >   CAST                                          8  ~2      <array>
          4        ASSIGN                                           ~3      !0, ~2
          5        BOOL                                             ~1      ~3
   58     6    >   INIT_FCALL                                               'object_handle'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $4      
          9      > RETURN                                                   $4
   59    10*     > RETURN                                                   null

End of function abc

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.22 ms | 1415 KiB | 37 Q