3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $foo; public function __construct($foo) { $this->foo = $foo; } public function foo() { return $this->foo; } public function Hello() { return 'Hello World!'; } } function PHP(...$args) { if(isset($args[0]) && !empty($args[0])) { $class = $args[0]; $string = '$obj = new '.$class; if(isset($args[1])) { $arguments = $args; $string .= '('.$args[1]; array_shift($arguments); array_shift($arguments); foreach($arguments as $arg) { if(is_string($arg)) { $string .= ', \''.$arg.'\''; } else { $string .= ', '.$arg; } } $string .= ')'; } $string .= ';'; eval($string); return $obj; } else { print('You must a define a class to set as object.'); } } $obj = PHP('A', 1); echo($obj->foo());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DBTi6
function name:  (null)
number of ops:  9
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   INIT_FCALL                                               'php'
          1        SEND_VAL                                                 'A'
          2        SEND_VAL                                                 1
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   42     5        INIT_METHOD_CALL                                         !0, 'foo'
          6        DO_FCALL                                      0  $3      
          7        ECHO                                                     $3
          8      > RETURN                                                   1

Function php:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 40
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 36
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 34
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 34
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 36
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/DBTi6
function name:  PHP
number of ops:  42
compiled vars:  !0 = $args, !1 = $class, !2 = $string, !3 = $arguments, !4 = $arg, !5 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV_VARIADIC                                    !0      
   15     1        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !0, 0
          2      > JMPZ_EX                                          ~6      ~6, ->6
          3    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~7      !0, 0
          4        BOOL_NOT                                         ~8      ~7
          5        BOOL                                             ~6      ~8
          6    > > JMPZ                                                     ~6, ->40
   16     7    >   FETCH_DIM_R                                      ~9      !0, 0
          8        ASSIGN                                                   !1, ~9
   17     9        CONCAT                                           ~11     '%24obj+%3D+new+', !1
         10        ASSIGN                                                   !2, ~11
   18    11        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 1
         12      > JMPZ                                                     ~13, ->36
   19    13    >   ASSIGN                                                   !3, !0
   20    14        FETCH_DIM_R                                      ~15     !0, 1
         15        CONCAT                                           ~16     '%28', ~15
         16        ASSIGN_OP                                     8          !2, ~16
   21    17        INIT_FCALL                                               'array_shift'
         18        SEND_REF                                                 !3
         19        DO_ICALL                                                 
   22    20        INIT_FCALL                                               'array_shift'
         21        SEND_REF                                                 !3
         22        DO_ICALL                                                 
   23    23      > FE_RESET_R                                       $20     !3, ->34
         24    > > FE_FETCH_R                                               $20, !4, ->34
   24    25    >   TYPE_CHECK                                   64          !4
         26      > JMPZ                                                     ~21, ->31
   25    27    >   CONCAT                                           ~22     '%2C+%27', !4
         28        CONCAT                                           ~23     ~22, '%27'
         29        ASSIGN_OP                                     8          !2, ~23
         30      > JMP                                                      ->33
   28    31    >   CONCAT                                           ~25     '%2C+', !4
         32        ASSIGN_OP                                     8          !2, ~25
   23    33    > > JMP                                                      ->24
         34    >   FE_FREE                                                  $20
   31    35        ASSIGN_OP                                     8          !2, '%29'
   33    36    >   ASSIGN_OP                                     8          !2, '%3B'
   34    37        INCLUDE_OR_EVAL                                          !2, EVAL
   35    38      > RETURN                                                   !5
         39*       JMP                                                      ->41
   38    40    >   ECHO                                                     'You+must+a+define+a+class+to+set+as+object.'
   40    41      > RETURN                                                   null

End of function php

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

End of function __construct

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DBTi6
function name:  foo
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_OBJ_R                                      ~0      'foo'
          1      > RETURN                                                   ~0
    9     2*     > RETURN                                                   null

End of function foo

Function hello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DBTi6
function name:  Hello
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E > > RETURN                                                   'Hello+World%21'
   12     1*     > RETURN                                                   null

End of function hello

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.27 ms | 1407 KiB | 16 Q