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]; if(class_exists($class)) { $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('This class do not exists.'); } } else { print('You must a define a class to set as object.'); } } $obj = PHP('A', 'foo'); echo($obj->foo());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dBJZX
function name:  (null)
number of ops:  9
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   INIT_FCALL                                               'php'
          1        SEND_VAL                                                 'A'
          2        SEND_VAL                                                 'foo'
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   47     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 = 46
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 44
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 40
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 38
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 38
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 35
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
Branch analysis from position: 40
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/dBJZX
function name:  PHP
number of ops:  48
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, ->46
   16     7    >   FETCH_DIM_R                                      ~9      !0, 0
          8        ASSIGN                                                   !1, ~9
   17     9        INIT_FCALL                                               'class_exists'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $11     
         12      > JMPZ                                                     $11, ->44
   18    13    >   CONCAT                                           ~12     '%24obj+%3D+new+', !1
         14        ASSIGN                                                   !2, ~12
   19    15        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 1
         16      > JMPZ                                                     ~14, ->40
   20    17    >   ASSIGN                                                   !3, !0
   21    18        FETCH_DIM_R                                      ~16     !0, 1
         19        CONCAT                                           ~17     '%28', ~16
         20        ASSIGN_OP                                     8          !2, ~17
   22    21        INIT_FCALL                                               'array_shift'
         22        SEND_REF                                                 !3
         23        DO_ICALL                                                 
   23    24        INIT_FCALL                                               'array_shift'
         25        SEND_REF                                                 !3
         26        DO_ICALL                                                 
   24    27      > FE_RESET_R                                       $21     !3, ->38
         28    > > FE_FETCH_R                                               $21, !4, ->38
   25    29    >   TYPE_CHECK                                   64          !4
         30      > JMPZ                                                     ~22, ->35
   26    31    >   CONCAT                                           ~23     '%2C+%27', !4
         32        CONCAT                                           ~24     ~23, '%27'
         33        ASSIGN_OP                                     8          !2, ~24
         34      > JMP                                                      ->37
   29    35    >   CONCAT                                           ~26     '%2C+', !4
         36        ASSIGN_OP                                     8          !2, ~26
   24    37    > > JMP                                                      ->28
         38    >   FE_FREE                                                  $21
   32    39        ASSIGN_OP                                     8          !2, '%29'
   34    40    >   ASSIGN_OP                                     8          !2, '%3B'
   35    41        INCLUDE_OR_EVAL                                          !2, EVAL
   36    42      > RETURN                                                   !5
         43*       JMP                                                      ->45
   39    44    >   ECHO                                                     'This+class+do+not+exists.'
         45      > JMP                                                      ->47
   43    46    >   ECHO                                                     'You+must+a+define+a+class+to+set+as+object.'
   45    47    > > 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/dBJZX
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/dBJZX
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/dBJZX
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:
172.02 ms | 1407 KiB | 18 Q