3v4l.org

run code in 500+ PHP versions simultaneously
<?php function debug($msg){ fwrite(STDOUT, sprintf("[Debug] %s\n", $msg)); } // capture any unexpected output and exit execution ob_start(function($buffer, $phase){ // prevent exit on ob_end_*() if(($phase & PHP_OUTPUT_HANDLER_FINAL) === 0){ $f = new class ($buffer) { public function __construct(private $buffer) {} public function __destruct() { debug('exit call'); exit(); // or // throw new UnexpectedOutputException($this->buffer); } }; } debug(sprintf("callback called, buffer: %s, type: %d", var_export($buffer, true), $phase)); // prevent buffer call return null; }, 1); // do some work on shutdown register_shutdown_function(function() { debug('ob_end_clean'); ob_end_clean(); debug('shutting down'); }); debug('echo x1'); echo 'x1'; debug('echo x2'); echo 'x2';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZNr6L
function name:  (null)
number of ops:  18
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                                   'ob_start'
          1        DECLARE_LAMBDA_FUNCTION                              ~0      [0]
   25     2        SEND_VAL                                                     ~0
          3        SEND_VAL                                                     1
    8     4        DO_ICALL                                                     
   28     5        INIT_FCALL                                                   'register_shutdown_function'
          6        DECLARE_LAMBDA_FUNCTION                              ~2      [1]
   32     7        SEND_VAL                                                     ~2
   28     8        DO_ICALL                                                     
   34     9        INIT_FCALL                                                   'debug'
         10        SEND_VAL                                                     'echo+x1'
         11        DO_FCALL                                          0          
   35    12        ECHO                                                         'x1'
   37    13        INIT_FCALL                                                   'debug'
         14        SEND_VAL                                                     'echo+x2'
         15        DO_FCALL                                          0          
   38    16        ECHO                                                         'x2'
         17      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/ZNr6L
function name:  {closure:/in/ZNr6L:8}
number of ops:  24
compiled vars:  !0 = $buffer, !1 = $phase, !2 = $f
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   10     2        BW_AND                                               ~3      !1, 8
          3        IS_IDENTICAL                                                 ~3, 0
          4      > JMPZ                                                         ~4, ->10
   11     5    >   DECLARE_ANON_CLASS                                   <unknown> 
          6        NEW                                                  $6      $5
          7        SEND_VAR_EX                                                  !0
          8        DO_FCALL                                          0          
          9        ASSIGN                                                       !2, $6
   21    10    >   INIT_FCALL                                                   'debug'
         11        INIT_FCALL                                                   'var_export'
         12        SEND_VAR                                                     !0
         13        SEND_VAL                                                     <true>
         14        DO_ICALL                                             $9      
         15        ROPE_INIT                                         4  ~12     'callback+called%2C+buffer%3A+'
         16        ROPE_ADD                                          1  ~12     ~12, $9
         17        ROPE_ADD                                          2  ~12     ~12, '%2C+type%3A+'
         18        CAST                                              4  ~10     !1
         19        ROPE_END                                          3  ~11     ~12, ~10
         20        SEND_VAL                                                     ~11
         21        DO_FCALL                                          0          
   24    22      > RETURN                                                       null
   25    23*     > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZNr6L
function name:  {closure:/in/ZNr6L:28}
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                                   'debug'
          1        SEND_VAL                                                     'ob_end_clean'
          2        DO_FCALL                                          0          
   30     3        INIT_FCALL                                                   'ob_end_clean'
          4        DO_ICALL                                                     
   31     5        INIT_FCALL                                                   'debug'
          6        SEND_VAL                                                     'shutting+down'
          7        DO_FCALL                                          0          
   32     8      > RETURN                                                       null

End of Dynamic Function 1

Function debug:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZNr6L
function name:  debug
number of ops:  10
compiled vars:  !0 = $msg
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        INIT_FCALL                                                   'fwrite'
          2        FETCH_CONSTANT                                       ~1      'STDOUT'
          3        SEND_VAL                                                     ~1
          4        ROPE_INIT                                         3  ~3      '%5BDebug%5D+'
          5        ROPE_ADD                                          1  ~3      ~3, !0
          6        ROPE_END                                          2  ~2      ~3, '%0A'
          7        SEND_VAL                                                     ~2
          8        DO_ICALL                                                     
    5     9      > RETURN                                                       null

End of function debug

Class class@anonymous:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZNr6L
function name:  __construct
number of ops:  4
compiled vars:  !0 = $buffer
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   RECV                                                 !0      
          1        ASSIGN_OBJ                                                   'buffer'
          2        OP_DATA                                                      !0
          3      > RETURN                                                       null

End of function __construct

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 61) Position 1 = -2
filename:       /in/ZNr6L
function name:  __destruct
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                                   'debug'
          1        SEND_VAL                                                     'exit+call'
          2        DO_FCALL                                          0          
   15     3      > INIT_FCALL                                                   'exit'
          4*       DO_ICALL                                                     
   18     5*     > RETURN                                                       null

End of function __destruct

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
132.9 ms | 494 KiB | 19 Q