3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Greeter { private $boss; private $guests = array(); function __construct($boss) { $this->boss = $boss; } // returns welcome message for last guest public function greet() { if(count($this->guests) == 0){ $name = null; } else{ $name = array_pop($this->guests); } if ($name == $this->boss) { return 'Very very welcome, '.$name; } else { return 'Welcome, '. $name; } } public function enters($name) { array_push($this->guests,$name); } } // For testing purposes (do not submit uncommented): $g = new Greeter('Chuck'); $g->enters('John'); $g->enters('John2'); echo $g->greet(); echo $g->greet();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KUWIj
function name:  (null)
number of ops:  17
compiled vars:  !0 = $g
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   37     0  E >   NEW                                                  $1      'Greeter'
          1        SEND_VAL_EX                                                  'Chuck'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $1
   38     4        INIT_METHOD_CALL                                             !0, 'enters'
          5        SEND_VAL_EX                                                  'John'
          6        DO_FCALL                                          0          
   39     7        INIT_METHOD_CALL                                             !0, 'enters'
          8        SEND_VAL_EX                                                  'John2'
          9        DO_FCALL                                          0          
   40    10        INIT_METHOD_CALL                                             !0, 'greet'
         11        DO_FCALL                                          0  $6      
         12        ECHO                                                         $6
   41    13        INIT_METHOD_CALL                                             !0, 'greet'
         14        DO_FCALL                                          0  $7      
         15        ECHO                                                         $7
         16      > RETURN                                                       1

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

End of function __construct

Function greet:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
Branch analysis from position: 17
filename:       /in/KUWIj
function name:  greet
number of ops:  20
compiled vars:  !0 = $name
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   FETCH_OBJ_R                                          ~1      'guests'
          1        COUNT                                                ~2      ~1
          2        IS_EQUAL                                                     ~2, 0
          3      > JMPZ                                                         ~3, ->6
   15     4    >   ASSIGN                                                       !0, null
   14     5      > JMP                                                          ->11
   18     6    >   INIT_FCALL                                                   'array_pop'
          7        FETCH_OBJ_W                                          $5      'guests'
          8        SEND_REF                                                     $5
          9        DO_ICALL                                             $6      
         10        ASSIGN                                                       !0, $6
   22    11    >   FETCH_OBJ_R                                          ~8      'boss'
         12        IS_EQUAL                                                     !0, ~8
         13      > JMPZ                                                         ~9, ->17
   23    14    >   CONCAT                                               ~10     'Very+very+welcome%2C+', !0
         15      > RETURN                                                       ~10
   22    16*       JMP                                                          ->19
   25    17    >   CONCAT                                               ~11     'Welcome%2C+', !0
         18      > RETURN                                                       ~11
   27    19*     > RETURN                                                       null

End of function greet

Function enters:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KUWIj
function name:  enters
number of ops:  7
compiled vars:  !0 = $name
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   29     0  E >   RECV                                                 !0      
   31     1        INIT_FCALL                                                   'array_push'
          2        FETCH_OBJ_W                                          $1      'guests'
          3        SEND_REF                                                     $1
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                                     
   32     6      > RETURN                                                       null

End of function enters

End of class Greeter.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
137.8 ms | 3330 KiB | 15 Q