3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Tag { private $name; private $attrs = array(); private $content = null; function __construct($name) { $this->name = $name; } function __toString() { $code = "<" . $this->name; foreach($this->attrs as $name => $val) { $code .= " " . $name . "=\"$val\""; } $code .= ">" . (!is_null($this->content) ? $this->content : '') . "</" . $this->name. ">"; return $code; } function addClass($className) { $this->attrs["class"] .= $className." "; return $this; } function addTitle($title) { $this->attrs["title"] = $title; return $this; } function addContent($content) { $this->content = $content; return $this; } function stringify() { return $this; } } error_reporting(~E_NOTICE); $paragraph = new Tag('p'); echo $paragraph ->addClass("test") ->addTitle("Kubo2's testing paragraph") ->addContent("This is Kubo2's testing paragraph. It relates to http://djpw.cz/154725") ->stringify();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Wg71
function name:  (null)
number of ops:  21
compiled vars:  !0 = $paragraph
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'tag'
   41     1        INIT_FCALL                                                   'error_reporting'
          2        SEND_VAL                                                     -9
          3        DO_ICALL                                                     
   42     4        NEW                                                  $2      'Tag'
          5        SEND_VAL_EX                                                  'p'
          6        DO_FCALL                                          0          
          7        ASSIGN                                                       !0, $2
   44     8        INIT_METHOD_CALL                                             !0, 'addClass'
          9        SEND_VAL_EX                                                  'test'
         10        DO_FCALL                                          0  $5      
   45    11        INIT_METHOD_CALL                                             $5, 'addTitle'
         12        SEND_VAL_EX                                                  'Kubo2%27s+testing+paragraph'
         13        DO_FCALL                                          0  $6      
   46    14        INIT_METHOD_CALL                                             $6, 'addContent'
         15        SEND_VAL_EX                                                  'This+is+Kubo2%27s+testing+paragraph.+It+relates+to+http%3A%2F%2Fdjpw.cz%2F154725'
         16        DO_FCALL                                          0  $7      
   47    17        INIT_METHOD_CALL                                             $7, 'stringify'
         18        DO_FCALL                                          0  $8      
         19        ECHO                                                         $8
         20      > RETURN                                                       1

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

End of function __construct

Function __tostring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/4Wg71
function name:  __toString
number of ops:  33
compiled vars:  !0 = $code, !1 = $val, !2 = $name
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   FETCH_OBJ_R                                          ~3      'name'
          1        CONCAT                                               ~4      '%3C', ~3
          2        ASSIGN                                                       !0, ~4
   14     3        FETCH_OBJ_R                                          ~6      'attrs'
          4      > FE_RESET_R                                           $7      ~6, ->14
          5    > > FE_FETCH_R                                           ~8      $7, !1, ->14
          6    >   ASSIGN                                                       !2, ~8
   15     7        CONCAT                                               ~10     '+', !2
          8        ROPE_INIT                                         3  ~12     '%3D%22'
          9        ROPE_ADD                                          1  ~12     ~12, !1
         10        ROPE_END                                          2  ~11     ~12, '%22'
         11        CONCAT                                               ~14     ~10, ~11
         12        ASSIGN_OP                                         8          !0, ~14
   14    13      > JMP                                                          ->5
         14    >   FE_FREE                                                      $7
   17    15        FETCH_OBJ_R                                          ~16     'content'
         16        TYPE_CHECK                                        2  ~17     ~16
         17        BOOL_NOT                                             ~18     ~17
         18      > JMPZ                                                         ~18, ->22
         19    >   FETCH_OBJ_R                                          ~19     'content'
         20        QM_ASSIGN                                            ~20     ~19
         21      > JMP                                                          ->23
         22    >   QM_ASSIGN                                            ~20     ''
         23    >   CONCAT                                               ~21     '%3E', ~20
         24        CONCAT                                               ~22     ~21, '%3C%2F'
         25        FETCH_OBJ_R                                          ~23     'name'
         26        CONCAT                                               ~24     ~22, ~23
         27        CONCAT                                               ~25     ~24, '%3E'
         28        ASSIGN_OP                                         8          !0, ~25
   18    29        VERIFY_RETURN_TYPE                                           !0
         30      > RETURN                                                       !0
   19    31*       VERIFY_RETURN_TYPE                                           
         32*     > RETURN                                                       null

End of function __tostring

Function addclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Wg71
function name:  addClass
number of ops:  8
compiled vars:  !0 = $className
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   RECV                                                 !0      
   22     1        CONCAT                                               ~3      !0, '+'
          2        FETCH_OBJ_RW                                         $1      'attrs'
          3        ASSIGN_DIM_OP                    .=               8          $1, 'class'
          4        OP_DATA                                                      ~3
   23     5        FETCH_THIS                                           ~4      
          6      > RETURN                                                       ~4
   24     7*     > RETURN                                                       null

End of function addclass

Function addtitle:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Wg71
function name:  addTitle
number of ops:  7
compiled vars:  !0 = $title
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   26     0  E >   RECV                                                 !0      
   27     1        FETCH_OBJ_W                                          $1      'attrs'
          2        ASSIGN_DIM                                                   $1, 'title'
          3        OP_DATA                                                      !0
   28     4        FETCH_THIS                                           ~3      
          5      > RETURN                                                       ~3
   29     6*     > RETURN                                                       null

End of function addtitle

Function addcontent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Wg71
function name:  addContent
number of ops:  6
compiled vars:  !0 = $content
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   31     0  E >   RECV                                                 !0      
   32     1        ASSIGN_OBJ                                                   'content'
          2        OP_DATA                                                      !0
   33     3        FETCH_THIS                                           ~2      
          4      > RETURN                                                       ~2
   34     5*     > RETURN                                                       null

End of function addcontent

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

End of function stringify

End of class Tag.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
181.31 ms | 2919 KiB | 14 Q