3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Renderer { function render(array $_data) { // normally you'd have some file you'd render from... $_data = $this->escapeData($_data); extract($_data, EXTR_SKIP); return <<<LIST {$foo}\n {$bar}\n {$baz}\n LIST; } private function escapeData(array $data) { $safe = []; foreach ($data as $var => $value) { if (is_array($value)) { $safe[$var] = $this->escapeData($value); } else { $safe[$var] = htmlspecialchars($value); } } return $safe; } } $renderer = new Renderer(); $unsafe = ['foo' => '<script>alert("xss");</script>', 'bar' => '<b>something</b>', 'baz' => '<i>foo</i>']; echo $renderer->render($unsafe);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6lcUt
function name:  (null)
number of ops:  9
compiled vars:  !0 = $renderer, !1 = $unsafe
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $2      'Renderer'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   33     3        ASSIGN                                                   !1, <array>
   34     4        INIT_METHOD_CALL                                         !0, 'render'
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $6      
          7        ECHO                                                     $6
          8      > RETURN                                                   1

Class Renderer:
Function render:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6lcUt
function name:  render
number of ops:  17
compiled vars:  !0 = $_data, !1 = $foo, !2 = $bar, !3 = $baz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        INIT_METHOD_CALL                                         'escapeData'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !0, $4
    8     5        INIT_FCALL                                               'extract'
          6        SEND_REF                                                 !0
          7        SEND_VAL                                                 1
          8        DO_ICALL                                                 
   10     9        ROPE_INIT                                     6  ~8      !1
         10        ROPE_ADD                                      1  ~8      ~8, '%0A%0A'
   11    11        ROPE_ADD                                      2  ~8      ~8, !2
         12        ROPE_ADD                                      3  ~8      ~8, '%0A%0A'
   12    13        ROPE_ADD                                      4  ~8      ~8, !3
         14        ROPE_END                                      5  ~7      ~8, '%0A'
         15      > RETURN                                                   ~7
   15    16*     > RETURN                                                   null

End of function render

Function escapedata:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/6lcUt
function name:  escapeData
number of ops:  22
compiled vars:  !0 = $data, !1 = $safe, !2 = $value, !3 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        ASSIGN                                                   !1, <array>
   19     2      > FE_RESET_R                                       $5      !0, ->19
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->19
          4    >   ASSIGN                                                   !3, ~6
   20     5        TYPE_CHECK                                  128          !2
          6      > JMPZ                                                     ~8, ->13
   21     7    >   INIT_METHOD_CALL                                         'escapeData'
          8        SEND_VAR                                                 !2
          9        DO_FCALL                                      0  $10     
         10        ASSIGN_DIM                                               !1, !3
         11        OP_DATA                                                  $10
         12      > JMP                                                      ->18
   23    13    >   INIT_FCALL                                               'htmlspecialchars'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                         $12     
         16        ASSIGN_DIM                                               !1, !3
         17        OP_DATA                                                  $12
   19    18    > > JMP                                                      ->3
         19    >   FE_FREE                                                  $5
   27    20      > RETURN                                                   !1
   28    21*     > RETURN                                                   null

End of function escapedata

End of class Renderer.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.39 ms | 1400 KiB | 17 Q