3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MicroTemplateEngine { public $data = array(); private $tpl; function __construct($f) { $this->tpl = $f; } function __set($name, $value) { $this->data[$name] = $value; } function __toString() { $out = $this->tpl; foreach ($this->data as $_key => $_value) { $out = str_replace('#{' . $_key . '}', $_value, $out); } $out = preg_replace('/#{.*?}/' , '' , $out ); return $out; } } $t = new MicroTemplateEngine('<div>{inner}{{inner}}</div>'); $t->inner = 'oi'; echo $t;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vR7O1
function name:  (null)
number of ops:  9
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'microtemplateengine'
   26     1        NEW                                              $1      'MicroTemplateEngine'
          2        SEND_VAL_EX                                              '%3Cdiv%3E%7Binner%7D%7B%7Binner%7D%7D%3C%2Fdiv%3E'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   27     5        ASSIGN_OBJ                                               !0, 'inner'
          6        OP_DATA                                                  'oi'
   28     7        ECHO                                                     !0
          8      > RETURN                                                   1

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

End of function __construct

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vR7O1
function name:  __set
number of ops:  6
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        FETCH_OBJ_W                                      $2      'data'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   14     5      > RETURN                                                   null

End of function __set

Function __tostring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/vR7O1
function name:  __toString
number of ops:  26
compiled vars:  !0 = $out, !1 = $_value, !2 = $_key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   FETCH_OBJ_R                                      ~3      'tpl'
          1        ASSIGN                                                   !0, ~3
   18     2        FETCH_OBJ_R                                      ~5      'data'
          3      > FE_RESET_R                                       $6      ~5, ->15
          4    > > FE_FETCH_R                                       ~7      $6, !1, ->15
          5    >   ASSIGN                                                   !2, ~7
   19     6        INIT_FCALL                                               'str_replace'
          7        CONCAT                                           ~9      '%23%7B', !2
          8        CONCAT                                           ~10     ~9, '%7D'
          9        SEND_VAL                                                 ~10
         10        SEND_VAR                                                 !1
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $11     
         13        ASSIGN                                                   !0, $11
   18    14      > JMP                                                      ->4
         15    >   FE_FREE                                                  $6
   21    16        INIT_FCALL                                               'preg_replace'
         17        SEND_VAL                                                 '%2F%23%7B.%2A%3F%7D%2F'
         18        SEND_VAL                                                 ''
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $13     
         21        ASSIGN                                                   !0, $13
   22    22        VERIFY_RETURN_TYPE                                       !0
         23      > RETURN                                                   !0
   23    24*       VERIFY_RETURN_TYPE                                       
         25*     > RETURN                                                   null

End of function __tostring

End of class MicroTemplateEngine.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.47 ms | 1400 KiB | 17 Q