3v4l.org

run code in 300+ PHP versions simultaneously
<?php function safehtml ($str) { if (isset($GLOBALS['encoding'])) { $encoding = $GLOBALS['encoding']; } else { $encoding = 'ISO-8859-1'; } if (defined("ENT_XHTML")) { $newstr = htmlentities($str, ENT_COMPAT | ENT_XHTML, $encoding); // FIND-PHP-IGNORE-LINE-P$ } else { $newstr = htmlentities($str, ENT_COMPAT, $encoding); // FIND-PHP-IGNORE-LINE-PAUL } if (strlen($str) !== 0 && strlen($newstr) === 0) { trigger_error('safehtml returned blank string. Input: "'.$str.'"'); } return $newstr; } echo safehtml("¼script¾alert(¢XSS¢)¼/script¾");?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VUY4e
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'safehtml'
          1        SEND_VAL                                                 '%C2%BCscript%C2%BEalert%28%C2%A2XSS%C2%A2%29%C2%BC%2Fscript%C2%BE'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function safehtml:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 46) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
Branch analysis from position: 29
Branch analysis from position: 17
2 jumps found. (Code = 46) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
Branch analysis from position: 29
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
Branch analysis from position: 17
filename:       /in/VUY4e
function name:  safehtml
number of ops:  37
compiled vars:  !0 = $str, !1 = $encoding, !2 = $newstr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        FETCH_IS                                         ~3      'GLOBALS'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~3, 'encoding'
          3      > JMPZ                                                     ~4, ->8
    5     4    >   FETCH_R                      global              ~5      'GLOBALS'
          5        FETCH_DIM_R                                      ~6      ~5, 'encoding'
          6        ASSIGN                                                   !1, ~6
          7      > JMP                                                      ->9
    7     8    >   ASSIGN                                                   !1, 'ISO-8859-1'
    9     9    > > JMPZ                                                     <true>, ->17
   10    10    >   INIT_FCALL                                               'htmlentities'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 34
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $9      
         15        ASSIGN                                                   !2, $9
         16      > JMP                                                      ->23
   12    17    >   INIT_FCALL                                               'htmlentities'
         18        SEND_VAR                                                 !0
         19        SEND_VAL                                                 2
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $11     
         22        ASSIGN                                                   !2, $11
   14    23    >   STRLEN                                           ~13     !0
         24        IS_NOT_IDENTICAL                                 ~14     ~13, 0
         25      > JMPZ_EX                                          ~14     ~14, ->29
         26    >   STRLEN                                           ~15     !2
         27        IS_IDENTICAL                                     ~16     ~15, 0
         28        BOOL                                             ~14     ~16
         29    > > JMPZ                                                     ~14, ->35
   15    30    >   INIT_FCALL                                               'trigger_error'
         31        CONCAT                                           ~17     'safehtml+returned+blank+string.+Input%3A+%22', !0
         32        CONCAT                                           ~18     ~17, '%22'
         33        SEND_VAL                                                 ~18
         34        DO_ICALL                                                 
   17    35    > > RETURN                                                   !2
   18    36*     > RETURN                                                   null

End of function safehtml

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.31 ms | 1403 KiB | 18 Q