3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Math { const pi = 3.14; } class CircleMath extends Math { public static function calculateArea($radius) { return parent::pi * pow($radius, 2); } } class Circle { private $radius = 1.0; private $color = 'white'; private $coordinates = array('x' => 0, 'y' => 0); public function __construct() { $args = func_get_args(); foreach ($args as $arg) { if (is_numeric($arg)) { $this->radius = doubleval($arg); } else if (is_string($arg)) { $this->color = $arg; } else if (is_array()) { $this->coordinates = $arg; } } } public function calculateArea() { return CircleMath::calculateArea($this->radius); } public function get_radius() { return $this->radius; } public function get_color() { return $this->color; } public function get_coordinates() { return $this->coordinates; } } $className = 'Circle'; $circle = new $className(array('x' => 5, 'y' => 6)); print sprintf('The area of %s circle with radius %s and center positioned in (%s, %s) is: %s', $circle->get_color(), $circle->get_radius(), $circle->get_coordinates()['x'], $circle->get_coordinates()['y'], $circle->calculateArea()); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kMJBe
function name:  (null)
number of ops:  28
compiled vars:  !0 = $className, !1 = $circle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   ASSIGN                                                   !0, 'Circle'
   51     1        FETCH_CLASS                                   0  $3      !0
          2        NEW                                              $4      $3
          3        SEND_VAL_EX                                              <array>
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $4
   53     6        INIT_FCALL                                               'sprintf'
          7        SEND_VAL                                                 'The+area+of+%25s+circle+with+radius+%25s+and+center+positioned+in+%28%25s%2C+%25s%29+is%3A+%25s'
   54     8        INIT_METHOD_CALL                                         !1, 'get_color'
          9        DO_FCALL                                      0  $7      
         10        SEND_VAR                                                 $7
         11        INIT_METHOD_CALL                                         !1, 'get_radius'
         12        DO_FCALL                                      0  $8      
         13        SEND_VAR                                                 $8
         14        INIT_METHOD_CALL                                         !1, 'get_coordinates'
         15        DO_FCALL                                      0  $9      
         16        FETCH_DIM_R                                      ~10     $9, 'x'
         17        SEND_VAL                                                 ~10
   55    18        INIT_METHOD_CALL                                         !1, 'get_coordinates'
         19        DO_FCALL                                      0  $11     
         20        FETCH_DIM_R                                      ~12     $11, 'y'
         21        SEND_VAL                                                 ~12
         22        INIT_METHOD_CALL                                         !1, 'calculateArea'
         23        DO_FCALL                                      0  $13     
         24        SEND_VAR                                                 $13
         25        DO_ICALL                                         $14     
         26        ECHO                                                     $14
   57    27      > RETURN                                                   1

Class Math: [no user functions]
Class CircleMath:
Function calculatearea:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kMJBe
function name:  calculateArea
number of ops:  9
compiled vars:  !0 = $radius
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        FETCH_CLASS_CONSTANT                             ~1      'pi'
          2        INIT_FCALL                                               'pow'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 2
          5        DO_ICALL                                         $2      
          6        MUL                                              ~3      $2, ~1
          7      > RETURN                                                   ~3
   10     8*     > RETURN                                                   null

End of function calculatearea

End of class CircleMath.

Class Circle:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 23
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 22
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/kMJBe
function name:  __construct
number of ops:  25
compiled vars:  !0 = $args, !1 = $arg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FUNC_GET_ARGS                                    ~2      
          1        ASSIGN                                                   !0, ~2
   21     2      > FE_RESET_R                                       $4      !0, ->23
          3    > > FE_FETCH_R                                               $4, !1, ->23
   22     4    >   INIT_FCALL                                               'is_numeric'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $5      
          7      > JMPZ                                                     $5, ->12
   23     8    >   CAST                                          5  ~7      !1
          9        ASSIGN_OBJ                                               'radius'
         10        OP_DATA                                                  ~7
         11      > JMP                                                      ->22
   24    12    >   TYPE_CHECK                                   64          !1
         13      > JMPZ                                                     ~8, ->17
   25    14    >   ASSIGN_OBJ                                               'color'
         15        OP_DATA                                                  !1
         16      > JMP                                                      ->22
   26    17    >   INIT_FCALL                                               'is_array'
         18        DO_ICALL                                         $10     
         19      > JMPZ                                                     $10, ->22
   27    20    >   ASSIGN_OBJ                                               'coordinates'
         21        OP_DATA                                                  !1
   21    22    > > JMP                                                      ->3
         23    >   FE_FREE                                                  $4
   30    24      > RETURN                                                   null

End of function __construct

Function calculatearea:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kMJBe
function name:  calculateArea
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_STATIC_METHOD_CALL                                  'CircleMath', 'calculateArea'
          1        FETCH_OBJ_R                                      ~0      'radius'
          2        SEND_VAL                                                 ~0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   34     5*     > RETURN                                                   null

End of function calculatearea

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

End of function get_radius

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

End of function get_color

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

End of function get_coordinates

End of class Circle.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.2 ms | 1396 KiB | 21 Q