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... 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[$key] = $this->escapeData($value); } else { $safe[$key] = 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/dZPiQ
function name:  (null)
number of ops:  9
compiled vars:  !0 = $renderer, !1 = $unsafe
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   NEW                                              $2      'Renderer'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   32     3        ASSIGN                                                   !1, <array>
   33     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/dZPiQ
function name:  render
number of ops:  13
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_FCALL                                               'extract'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 1
          4        DO_ICALL                                                 
    9     5        ROPE_INIT                                     6  ~6      !1
          6        ROPE_ADD                                      1  ~6      ~6, '%0A%0A'
   10     7        ROPE_ADD                                      2  ~6      ~6, !2
          8        ROPE_ADD                                      3  ~6      ~6, '%0A%0A'
   11     9        ROPE_ADD                                      4  ~6      ~6, !3
         10        ROPE_END                                      5  ~5      ~6, '%0A'
         11      > RETURN                                                   ~5
   14    12*     > 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/dZPiQ
function name:  escapeData
number of ops:  22
compiled vars:  !0 = $data, !1 = $safe, !2 = $value, !3 = $var, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        ASSIGN                                                   !1, <array>
   18     2      > FE_RESET_R                                       $6      !0, ->19
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->19
          4    >   ASSIGN                                                   !3, ~7
   19     5        TYPE_CHECK                                  128          !2
          6      > JMPZ                                                     ~9, ->13
   20     7    >   INIT_METHOD_CALL                                         'escapeData'
          8        SEND_VAR                                                 !2
          9        DO_FCALL                                      0  $11     
         10        ASSIGN_DIM                                               !1, !4
         11        OP_DATA                                                  $11
         12      > JMP                                                      ->18
   22    13    >   INIT_FCALL                                               'htmlspecialchars'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                         $13     
         16        ASSIGN_DIM                                               !1, !4
         17        OP_DATA                                                  $13
   18    18    > > JMP                                                      ->3
         19    >   FE_FREE                                                  $6
   26    20      > RETURN                                                   !1
   27    21*     > RETURN                                                   null

End of function escapedata

End of class Renderer.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.95 ms | 1400 KiB | 17 Q