3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { public $i = 0; function createANewBar() { ++$i; return null; } } class no_construct { } class a_construct { public function __construct() { } } $myFoo = new foo; echo $myFoo->i.PHP_EOL; $class = 'no_construct'; $object = new $class($myFoo->createANewBar()); echo $myFoo->i.PHP_EOL; $object = new no_construct($myFoo->createANewBar()); echo $myFoo->i.PHP_EOL; $class = 'a_construct'; $object = new $class($myFoo->createANewBar()); echo $myFoo->i.PHP_EOL; $object = new a_construct($myFoo->createANewBar()); echo $myFoo->i.PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BFF9Y
function name:  (null)
number of ops:  47
compiled vars:  !0 = $myFoo, !1 = $class, !2 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   NEW                                              $3      'foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   11     3        FETCH_OBJ_R                                      ~6      !0, 'i'
          4        CONCAT                                           ~7      ~6, '%0A'
          5        ECHO                                                     ~7
   13     6        ASSIGN                                                   !1, 'no_construct'
   15     7        FETCH_CLASS                                   0  $9      !1
          8        NEW                                              $10     $9
          9        INIT_METHOD_CALL                                         !0, 'createANewBar'
         10        DO_FCALL                                      0  $11     
         11        SEND_VAR_NO_REF_EX                                       $11
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !2, $10
   17    14        FETCH_OBJ_R                                      ~14     !0, 'i'
         15        CONCAT                                           ~15     ~14, '%0A'
         16        ECHO                                                     ~15
   19    17        NEW                                              $16     'no_construct'
         18        INIT_METHOD_CALL                                         !0, 'createANewBar'
         19        DO_FCALL                                      0  $17     
         20        SEND_VAR_NO_REF_EX                                       $17
         21        DO_FCALL                                      0          
         22        ASSIGN                                                   !2, $16
   21    23        FETCH_OBJ_R                                      ~20     !0, 'i'
         24        CONCAT                                           ~21     ~20, '%0A'
         25        ECHO                                                     ~21
   23    26        ASSIGN                                                   !1, 'a_construct'
   25    27        FETCH_CLASS                                   0  $23     !1
         28        NEW                                              $24     $23
         29        INIT_METHOD_CALL                                         !0, 'createANewBar'
         30        DO_FCALL                                      0  $25     
         31        SEND_VAR_NO_REF_EX                                       $25
         32        DO_FCALL                                      0          
         33        ASSIGN                                                   !2, $24
   27    34        FETCH_OBJ_R                                      ~28     !0, 'i'
         35        CONCAT                                           ~29     ~28, '%0A'
         36        ECHO                                                     ~29
   29    37        NEW                                              $30     'a_construct'
         38        INIT_METHOD_CALL                                         !0, 'createANewBar'
         39        DO_FCALL                                      0  $31     
         40        SEND_VAR_NO_REF_EX                                       $31
         41        DO_FCALL                                      0          
         42        ASSIGN                                                   !2, $30
   31    43        FETCH_OBJ_R                                      ~34     !0, 'i'
         44        CONCAT                                           ~35     ~34, '%0A'
         45        ECHO                                                     ~35
         46      > RETURN                                                   1

Class foo:
Function createanewbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BFF9Y
function name:  createANewBar
number of ops:  3
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   PRE_INC                                                  !0
          1      > RETURN                                                   null
          2*     > RETURN                                                   null

End of function createanewbar

End of class foo.

Class no_construct: [no user functions]
Class a_construct:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BFF9Y
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E > > RETURN                                                   null

End of function __construct

End of class a_construct.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.94 ms | 1399 KiB | 13 Q