3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Simplify { public static function Template($file, $variables) { $template = $file; preg_match_all("{{(\w*)}}", $template, $matches); foreach($matches[1] as $var) { if (array_key_exists($var, $variables)) { $output = str_replace('{{' . $var . '}}', $variables[$var], $template); } } echo $template; } } $template = "hfwlei ifaugweifg uwfgyakreu fvgw fwaeuif gonwiegf {{naam}} uywanfi awyuegfawuyegf {{email}}"; $vars = array("naam" => "Joran", "email" => "info@jorandesign.nl"); Simplify::Template($template, $vars);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k26mc
function name:  (null)
number of ops:  7
compiled vars:  !0 = $template, !1 = $vars
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, 'hfwlei+ifaugweifg+uwfgyakreu+fvgw+fwaeuif+gonwiegf+%7B%7Bnaam%7D%7D+uywanfi+awyuegfawuyegf+%7B%7Bemail%7D%7D'
   18     1        ASSIGN                                                   !1, <array>
   19     2        INIT_STATIC_METHOD_CALL                                  'Simplify', 'Template'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0          
          6      > RETURN                                                   1

Class Simplify:
Function template:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 22
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
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/k26mc
function name:  Template
number of ops:  26
compiled vars:  !0 = $file, !1 = $variables, !2 = $template, !3 = $matches, !4 = $var, !5 = $output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ASSIGN                                                   !2, !0
    6     3        INIT_FCALL                                               'preg_match_all'
          4        SEND_VAL                                                 '%7B%7B%28%5Cw%2A%29%7D%7D'
          5        SEND_VAR                                                 !2
          6        SEND_REF                                                 !3
          7        DO_ICALL                                                 
    8     8        FETCH_DIM_R                                      ~8      !3, 1
          9      > FE_RESET_R                                       $9      ~8, ->23
         10    > > FE_FETCH_R                                               $9, !4, ->23
    9    11    >   ARRAY_KEY_EXISTS                                         !4, !1
         12      > JMPZ                                                     ~10, ->22
   10    13    >   INIT_FCALL                                               'str_replace'
         14        CONCAT                                           ~11     '%7B%7B', !4
         15        CONCAT                                           ~12     ~11, '%7D%7D'
         16        SEND_VAL                                                 ~12
         17        FETCH_DIM_R                                      ~13     !1, !4
         18        SEND_VAL                                                 ~13
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                         $14     
         21        ASSIGN                                                   !5, $14
    8    22    > > JMP                                                      ->10
         23    >   FE_FREE                                                  $9
   13    24        ECHO                                                     !2
   14    25      > RETURN                                                   null

End of function template

End of class Simplify.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.53 ms | 1400 KiB | 17 Q