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

End of function __tostring

End of class MicroTemplateEngine.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.29 ms | 1392 KiB | 19 Q