3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Example { public int $foo; public function __get($var) { echo "__get was called for '$var'\n"; return 999; } public function __set($var, $val) { echo "__set was called for '$var'\n"; $this->{$var} = $val; } } echo "Creating instance\n\n"; $example = new Example; echo "Reading before assignment\n"; try { var_dump($example->foo); } catch (Error $e) { echo "Error: ", $e->getMessage(), "\n"; } echo "Assigning\n"; $example->foo = 42; echo "\nUnsetting\n\n"; unset($example->foo); echo "Reading after unset\n"; try { var_dump($example->foo); } catch (Error $e) { echo "Error: ", $e->getMessage(), "\n"; } echo "Assigning after explicit unset\n"; $example->foo = 42;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 10
Branch analysis from position: 10
2 jumps found. (Code = 107) Position 1 = 11, Position 2 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Found catch point at position: 27
Branch analysis from position: 27
2 jumps found. (Code = 107) Position 1 = 28, Position 2 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C7rIF
function name:  (null)
number of ops:  37
compiled vars:  !0 = $example, !1 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   ECHO                                                         'Creating+instance%0A%0A'
   18     1        NEW                                                  $2      'Example'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $2
   20     4        ECHO                                                         'Reading+before+assignment%0A'
   21     5        INIT_FCALL                                                   'var_dump'
          6        FETCH_OBJ_R                                          ~5      !0, 'foo'
          7        SEND_VAL                                                     ~5
          8        DO_ICALL                                                     
          9      > JMP                                                          ->16
         10  E > > CATCH                                           last         'Error'
         11    >   ECHO                                                         'Error%3A+'
         12        INIT_METHOD_CALL                                             !1, 'getMessage'
         13        DO_FCALL                                          0  $7      
         14        ECHO                                                         $7
         15        ECHO                                                         '%0A'
   22    16    >   ECHO                                                         'Assigning%0A'
   23    17        ASSIGN_OBJ                                                   !0, 'foo'
         18        OP_DATA                                                      42
   25    19        ECHO                                                         '%0AUnsetting%0A%0A'
   26    20        UNSET_OBJ                                                    !0, 'foo'
   28    21        ECHO                                                         'Reading+after+unset%0A'
   29    22        INIT_FCALL                                                   'var_dump'
         23        FETCH_OBJ_R                                          ~9      !0, 'foo'
         24        SEND_VAL                                                     ~9
         25        DO_ICALL                                                     
         26      > JMP                                                          ->33
         27  E > > CATCH                                           last         'Error'
         28    >   ECHO                                                         'Error%3A+'
         29        INIT_METHOD_CALL                                             !1, 'getMessage'
         30        DO_FCALL                                          0  $11     
         31        ECHO                                                         $11
         32        ECHO                                                         '%0A'
   30    33    >   ECHO                                                         'Assigning+after+explicit+unset%0A'
   31    34        ASSIGN_OBJ                                                   !0, 'foo'
         35        OP_DATA                                                      42
   32    36      > RETURN                                                       1

Class Example:
Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C7rIF
function name:  __get
number of ops:  7
compiled vars:  !0 = $var
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
    7     1        ROPE_INIT                                         3  ~2      '__get+was+called+for+%27'
          2        ROPE_ADD                                          1  ~2      ~2, !0
          3        ROPE_END                                          2  ~1      ~2, '%27%0A'
          4        ECHO                                                         ~1
    8     5      > RETURN                                                       999
    9     6*     > RETURN                                                       null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C7rIF
function name:  __set
number of ops:  9
compiled vars:  !0 = $var, !1 = $val
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   12     2        ROPE_INIT                                         3  ~3      '__set+was+called+for+%27'
          3        ROPE_ADD                                          1  ~3      ~3, !0
          4        ROPE_END                                          2  ~2      ~3, '%27%0A'
          5        ECHO                                                         ~2
   13     6        ASSIGN_OBJ                                                   !0
          7        OP_DATA                                                      !1
   14     8      > RETURN                                                       null

End of function __set

End of class Example.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
176.12 ms | 1623 KiB | 14 Q