3v4l.org

run code in 500+ PHP versions simultaneously
<?php $a = 1; $b = 2; $content = <<<BLOCK <h1>Some Html</h1> <hr> {IF:($a + $b === 3)} <b>Yes :)</b> {ELSE} <b>No :(</b> {ENDIF} Another one... {IF:($a + $b === 4)} <b>:)</b> {ELSE} <b>:(</b> {ENDIF} Some more Text BLOCK; echo render($content); function render($content) { $match = preg_match_all('/{IF:\((.*?)\)}(.*?){ELSE}(.*?)({ENDIF})/s', $content, $matches, PREG_OFFSET_CAPTURE); if (!$match) { return $content; } $beforeIf = substr($content, 0, $matches[0][0][1]); $afterIf = substr($content, $matches[4][0][1] + strlen('{ENDIF}')); $evalCondition = eval('return (' . $matches[1][0][0] . ');'); if ($evalCondition) { $ifResult = $matches[2][0][0]; } else { $ifResult = $matches[3][0][0]; } return $beforeIf . $ifResult . render($afterIf); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jW9ND
function name:  (null)
number of ops:  17
compiled vars:  !0 = $a, !1 = $b, !2 = $content
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 1
    4     1        ASSIGN                                                       !1, 2
    7     2        ROPE_INIT                                         9  ~6      '++++%3Ch1%3ESome+Html%3C%2Fh1%3E%0A++++%3Chr%3E%0A++++%7BIF%3A%28'
    9     3        ROPE_ADD                                          1  ~6      ~6, !0
          4        ROPE_ADD                                          2  ~6      ~6, '+%2B+'
          5        ROPE_ADD                                          3  ~6      ~6, !1
          6        ROPE_ADD                                          4  ~6      ~6, '+%3D%3D%3D+3%29%7D%0A++++++++%3Cb%3EYes+%3A%29%3C%2Fb%3E%0A++++%7BELSE%7D%0A++++++++%3Cb%3ENo+%3A%28%3C%2Fb%3E%0A%09%7BENDIF%7D%0A%09%0A%09Another+one...%0A%09%7BIF%3A%28'
   16     7        ROPE_ADD                                          5  ~6      ~6, !0
          8        ROPE_ADD                                          6  ~6      ~6, '+%2B+'
          9        ROPE_ADD                                          7  ~6      ~6, !1
         10        ROPE_END                                          8  ~5      ~6, '+%3D%3D%3D+4%29%7D%0A++++++++%3Cb%3E%3A%29%3C%2Fb%3E%0A++++%7BELSE%7D%0A++++++++%3Cb%3E%3A%28%3C%2Fb%3E%0A%09%7BENDIF%7D%0A%09%0A%09Some+more+Text'
    6    11        ASSIGN                                                       !2, ~5
   25    12        INIT_FCALL_BY_NAME                                           'render'
         13        SEND_VAR_EX                                                  !2
         14        DO_FCALL                                          0  $12     
         15        ECHO                                                         $12
   48    16      > RETURN                                                       1

Function render:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 36
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jW9ND
function name:  render
number of ops:  47
compiled vars:  !0 = $content, !1 = $match, !2 = $matches, !3 = $beforeIf, !4 = $afterIf, !5 = $evalCondition, !6 = $ifResult
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   RECV                                                 !0      
   28     1        INIT_FCALL                                                   'preg_match_all'
          2        SEND_VAL                                                     '%2F%7BIF%3A%5C%28%28.%2A%3F%29%5C%29%7D%28.%2A%3F%29%7BELSE%7D%28.%2A%3F%29%28%7BENDIF%7D%29%2Fs'
          3        SEND_VAR                                                     !0
          4        SEND_REF                                                     !2
          5        SEND_VAL                                                     256
          6        DO_ICALL                                             $7      
          7        ASSIGN                                                       !1, $7
   30     8        BOOL_NOT                                             ~9      !1
          9      > JMPZ                                                         ~9, ->11
   31    10    > > RETURN                                                       !0
   34    11    >   FETCH_DIM_R                                          ~10     !2, 0
         12        FETCH_DIM_R                                          ~11     ~10, 0
         13        FETCH_DIM_R                                          ~12     ~11, 1
         14        FRAMELESS_ICALL_3                substr              ~13     !0, 0
         15        OP_DATA                                                      ~12
         16        ASSIGN                                                       !3, ~13
   35    17        FETCH_DIM_R                                          ~15     !2, 4
         18        FETCH_DIM_R                                          ~16     ~15, 0
         19        FETCH_DIM_R                                          ~17     ~16, 1
         20        ADD                                                  ~18     ~17, 7
         21        FRAMELESS_ICALL_2                substr              ~19     !0, ~18
         22        ASSIGN                                                       !4, ~19
   36    23        FETCH_DIM_R                                          ~21     !2, 1
         24        FETCH_DIM_R                                          ~22     ~21, 0
         25        FETCH_DIM_R                                          ~23     ~22, 0
         26        CONCAT                                               ~24     'return+%28', ~23
         27        CONCAT                                               ~25     ~24, '%29%3B'
         28        INCLUDE_OR_EVAL                                      $26     ~25, EVAL
         29        ASSIGN                                                       !5, $26
   38    30      > JMPZ                                                         !5, ->36
   39    31    >   FETCH_DIM_R                                          ~28     !2, 2
         32        FETCH_DIM_R                                          ~29     ~28, 0
         33        FETCH_DIM_R                                          ~30     ~29, 0
         34        ASSIGN                                                       !6, ~30
   38    35      > JMP                                                          ->40
   41    36    >   FETCH_DIM_R                                          ~32     !2, 3
         37        FETCH_DIM_R                                          ~33     ~32, 0
         38        FETCH_DIM_R                                          ~34     ~33, 0
         39        ASSIGN                                                       !6, ~34
   46    40    >   CONCAT                                               ~36     !3, !6
   47    41        INIT_FCALL_BY_NAME                                           'render'
         42        SEND_VAR_EX                                                  !4
         43        DO_FCALL                                          0  $37     
         44        CONCAT                                               ~38     ~36, $37
         45      > RETURN                                                       ~38
   48    46*     > RETURN                                                       null

End of function render

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.01 ms | 3343 KiB | 14 Q