3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $value = 42; public function property( $value = null ) { $ret = $this->value; if ( func_num_args() === 0 ) { echo "Called as getter!\n"; } else { echo "Called as setter!\n"; $this->value = $value; } return $ret; } } $foo = new Foo; echo "Calling as getter...\n"; var_dump( $foo->property() ); echo "Calling as setter...\n"; var_dump( $foo->property( 123 ) ); echo "Calling as setter, passing null...\n"; var_dump( $foo->property( null ) ); echo "Calling as getter...\n"; var_dump( $foo->property() );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A6aCc
function name:  (null)
number of ops:  30
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   20     3        ECHO                                                     'Calling+as+getter...%0A'
   21     4        INIT_FCALL                                               'var_dump'
          5        INIT_METHOD_CALL                                         !0, 'property'
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   22     9        ECHO                                                     'Calling+as+setter...%0A'
   23    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !0, 'property'
         12        SEND_VAL_EX                                              123
         13        DO_FCALL                                      0  $6      
         14        SEND_VAR                                                 $6
         15        DO_ICALL                                                 
   24    16        ECHO                                                     'Calling+as+setter%2C+passing+null...%0A'
   25    17        INIT_FCALL                                               'var_dump'
         18        INIT_METHOD_CALL                                         !0, 'property'
         19        SEND_VAL_EX                                              null
         20        DO_FCALL                                      0  $8      
         21        SEND_VAR                                                 $8
         22        DO_ICALL                                                 
   26    23        ECHO                                                     'Calling+as+getter...%0A'
   27    24        INIT_FCALL                                               'var_dump'
         25        INIT_METHOD_CALL                                         !0, 'property'
         26        DO_FCALL                                      0  $10     
         27        SEND_VAR                                                 $10
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Class Foo:
Function property:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A6aCc
function name:  property
number of ops:  13
compiled vars:  !0 = $value, !1 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV_INIT                                        !0      null
    7     1        FETCH_OBJ_R                                      ~2      'value'
          2        ASSIGN                                                   !1, ~2
    8     3        FUNC_NUM_ARGS                                    ~4      
          4        IS_IDENTICAL                                             ~4, 0
          5      > JMPZ                                                     ~5, ->8
    9     6    >   ECHO                                                     'Called+as+getter%21%0A'
          7      > JMP                                                      ->11
   11     8    >   ECHO                                                     'Called+as+setter%21%0A'
   12     9        ASSIGN_OBJ                                               'value'
         10        OP_DATA                                                  !0
   14    11    > > RETURN                                                   !1
   15    12*     > RETURN                                                   null

End of function property

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.09 ms | 1400 KiB | 15 Q