3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Stripper{ var $regex; var $stripped; var $decoded; var $current_encoding; var $result; function __construct(){ mb_internal_encoding('UTF-8'); //mb_regex_encoding("UTF-8"); setlocale(LC_ALL, ['de_DE@euro', 'de_DE', 'deu_deu']); } private function to_utf8( $string ) { // From http://w3.org/International/questions/qa-forms-utf-8.html if ( preg_match('%^(?: [\x09\x0A\x0D\x20-\x7E] # ASCII | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 )*$%xs', $string) ) { return $string; } else { return iconv( 'CP1252', 'UTF-8', $string); } } function convert($string, $targetEncoding = 'UTF-8'){ $current_encoding = mb_detect_encoding($string); if($current_encoding != $targetEncoding){ $string = mb_convert_encoding($string, $targetEncoding, mb_detect_encoding($string)); } $result = $string; return $result; } //this function returns characters, whitespace, underscores and linebreaks plus @ , and - function strip($string){ //$this->convert($string); $result = mb_ereg_replace("[^[:word:][:alnum:][:blank:][:space:]@,\-\.]*", "", $string); return $result; } //this function returns $digits of number and discards everything else function onlyNumbers($string, $digits=0){ //$this->convert($string); $result = mb_ereg_replace("[^\d]*", "", $string); if($digits > 0){ $result = substr($result, 0, $digits); } return $result; } function decode($string, $type="all"){ //$this->convert($string); if($type == "all" || $type == "strip"){ $string = stripslashes($string); } if ($type == "all" || $type == "decode"){ $string = urldecode($string); } $result = $string; return $result; } } //mb_detect_order ( mb_internal_encoding('UTF-8'); mb_http_output('UTF-8'); mb_http_input('UTF-8'); mb_language('uni'); mb_regex_encoding('UTF-8'); ob_start('mb_output_handler'); //var_dump(mb_regex_encoding()); //var_dump( mb_get_info()); $value = "Häslïchëräëÿüïöáéüúíóßñµç.,_-;()''\"\" "; //$value = $stripper->decode($value); //$value = $stripper->convert($value); echo "before strip :" . mb_detect_encoding($value) . " for $value<br />"; //$_POST[$key] = $purifier->purify($_POST[$key]); //$value = str_replace("ß","ss",$value); $stripper = new Stripper(); $value = $stripper->strip($value); echo "after strip :". mb_detect_encoding($value) . " for $value<br />"; //phpinfo();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EXQtl
function name:  (null)
number of ops:  45
compiled vars:  !0 = $value, !1 = $stripper
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   69     0  E >   INIT_FCALL                                               'mb_internal_encoding'
          1        SEND_VAL                                                 'UTF-8'
          2        DO_ICALL                                                 
   70     3        INIT_FCALL                                               'mb_http_output'
          4        SEND_VAL                                                 'UTF-8'
          5        DO_ICALL                                                 
   71     6        INIT_FCALL                                               'mb_http_input'
          7        SEND_VAL                                                 'UTF-8'
          8        DO_ICALL                                                 
   72     9        INIT_FCALL                                               'mb_language'
         10        SEND_VAL                                                 'uni'
         11        DO_ICALL                                                 
   73    12        INIT_FCALL                                               'mb_regex_encoding'
         13        SEND_VAL                                                 'UTF-8'
         14        DO_ICALL                                                 
   74    15        INIT_FCALL                                               'ob_start'
         16        SEND_VAL                                                 'mb_output_handler'
         17        DO_ICALL                                                 
   79    18        ASSIGN                                                   !0, 'H%C3%A4sl%C3%AFch%C3%ABr%C3%A4%C3%AB%C3%BF%C3%BC%C3%AF%C3%B6%C3%A1%C3%A9%C3%BC%C3%BA%C3%AD%C3%B3%C3%9F%C3%B1%C2%B5%C3%A7.%2C_-%3B%28%29%27%27%22%22+'
   84    19        INIT_FCALL                                               'mb_detect_encoding'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                         $9      
         22        CONCAT                                           ~10     'before+strip+%3A', $9
         23        ROPE_INIT                                     3  ~12     '+for+'
         24        ROPE_ADD                                      1  ~12     ~12, !0
         25        ROPE_END                                      2  ~11     ~12, '%3Cbr+%2F%3E'
         26        CONCAT                                           ~14     ~10, ~11
         27        ECHO                                                     ~14
   87    28        NEW                                              $15     'Stripper'
         29        DO_FCALL                                      0          
         30        ASSIGN                                                   !1, $15
   88    31        INIT_METHOD_CALL                                         !1, 'strip'
         32        SEND_VAR_EX                                              !0
         33        DO_FCALL                                      0  $18     
         34        ASSIGN                                                   !0, $18
   90    35        INIT_FCALL                                               'mb_detect_encoding'
         36        SEND_VAR                                                 !0
         37        DO_ICALL                                         $20     
         38        CONCAT                                           ~21     'after+strip+%3A', $20
         39        ROPE_INIT                                     3  ~23     '+for+'
         40        ROPE_ADD                                      1  ~23     ~23, !0
         41        ROPE_END                                      2  ~22     ~23, '%3Cbr+%2F%3E'
         42        CONCAT                                           ~25     ~21, ~22
         43        ECHO                                                     ~25
   91    44      > RETURN                                                   1

Class Stripper:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EXQtl
function name:  __construct
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'mb_internal_encoding'
          1        SEND_VAL                                                 'UTF-8'
          2        DO_ICALL                                                 
   12     3        INIT_FCALL                                               'setlocale'
          4        SEND_VAL                                                 6
          5        SEND_VAL                                                 <array>
          6        DO_ICALL                                                 
   13     7      > RETURN                                                   null

End of function __construct

Function to_utf8:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EXQtl
function name:  to_utf8
number of ops:  15
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%25%5E%28%3F%3A+%0A++++++++++++++++++++++%5B%5Cx09%5Cx0A%5Cx0D%5Cx20-%5Cx7E%5D++++++++++++%23+ASCII+%0A++++++++++++++++++++%7C+%5B%5CxC2-%5CxDF%5D%5B%5Cx80-%5CxBF%5D+++++++++++++%23+non-overlong+2-byte+%0A++++++++++++++++++++%7C+%5CxE0%5B%5CxA0-%5CxBF%5D%5B%5Cx80-%5CxBF%5D+++++++++%23+excluding+overlongs+%0A++++++++++++++++++++%7C+%5B%5CxE1-%5CxEC%5CxEE%5CxEF%5D%5B%5Cx80-%5CxBF%5D%7B2%7D++%23+straight+3-byte+%0A++++++++++++++++++++%7C+%5CxED%5B%5Cx80-%5Cx9F%5D%5B%5Cx80-%5CxBF%5D+++++++++%23+excluding+surrogates+%0A++++++++++++++++++++%7C+%5CxF0%5B%5Cx90-%5CxBF%5D%5B%5Cx80-%5CxBF%5D%7B2%7D++++++%23+planes+1-3+%0A++++++++++++++++++++%7C+%5B%5CxF1-%5CxF3%5D%5B%5Cx80-%5CxBF%5D%7B3%7D++++++++++%23+planes+4-15+%0A++++++++++++++++++++%7C+%5CxF4%5B%5Cx80-%5Cx8F%5D%5B%5Cx80-%5CxBF%5D%7B2%7D++++++%23+plane+16+%0A++++++++++++++++%29%2A%24%25xs'
   25     3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > JMPZ                                                     $1, ->8
   26     6    > > RETURN                                                   !0
          7*       JMP                                                      ->14
   28     8    >   INIT_FCALL_BY_NAME                                       'iconv'
          9        SEND_VAL_EX                                              'CP1252'
         10        SEND_VAL_EX                                              'UTF-8'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0  $2      
         13      > RETURN                                                   $2
   30    14*     > RETURN                                                   null

End of function to_utf8

Function convert:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/EXQtl
function name:  convert
number of ops:  20
compiled vars:  !0 = $string, !1 = $targetEncoding, !2 = $current_encoding, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'UTF-8'
   32     2        INIT_FCALL                                               'mb_detect_encoding'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !2, $4
   33     6        IS_NOT_EQUAL                                             !2, !1
          7      > JMPZ                                                     ~6, ->17
   34     8    >   INIT_FCALL                                               'mb_convert_encoding'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        INIT_FCALL                                               'mb_detect_encoding'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $7      
         14        SEND_VAR                                                 $7
         15        DO_ICALL                                         $8      
         16        ASSIGN                                                   !0, $8
   36    17    >   ASSIGN                                                   !3, !0
   37    18      > RETURN                                                   !3
   38    19*     > RETURN                                                   null

End of function convert

Function strip:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EXQtl
function name:  strip
number of ops:  9
compiled vars:  !0 = $string, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
   42     1        INIT_FCALL                                               'mb_ereg_replace'
          2        SEND_VAL                                                 '%5B%5E%5B%3Aword%3A%5D%5B%3Aalnum%3A%5D%5B%3Ablank%3A%5D%5B%3Aspace%3A%5D%40%2C%5C-%5C.%5D%2A'
          3        SEND_VAL                                                 ''
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        ASSIGN                                                   !1, $2
   43     7      > RETURN                                                   !1
   44     8*     > RETURN                                                   null

End of function strip

Function onlynumbers:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/EXQtl
function name:  onlyNumbers
number of ops:  18
compiled vars:  !0 = $string, !1 = $digits, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
   48     2        INIT_FCALL                                               'mb_ereg_replace'
          3        SEND_VAL                                                 '%5B%5E%5Cd%5D%2A'
          4        SEND_VAL                                                 ''
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !2, $3
   49     8        IS_SMALLER                                               0, !1
          9      > JMPZ                                                     ~5, ->16
   50    10    >   INIT_FCALL                                               'substr'
         11        SEND_VAR                                                 !2
         12        SEND_VAL                                                 0
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $6      
         15        ASSIGN                                                   !2, $6
   52    16    > > RETURN                                                   !2
   53    17*     > RETURN                                                   null

End of function onlynumbers

Function decode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
2 jumps found. (Code = 47) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
Branch analysis from position: 15
Branch analysis from position: 11
Branch analysis from position: 6
filename:       /in/EXQtl
function name:  decode
number of ops:  23
compiled vars:  !0 = $string, !1 = $type, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'all'
   57     2        IS_EQUAL                                         ~3      !1, 'all'
          3      > JMPNZ_EX                                         ~3      ~3, ->6
          4    >   IS_EQUAL                                         ~4      !1, 'strip'
          5        BOOL                                             ~3      ~4
          6    > > JMPZ                                                     ~3, ->11
   58     7    >   INIT_FCALL                                               'stripslashes'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $5      
         10        ASSIGN                                                   !0, $5
   60    11    >   IS_EQUAL                                         ~7      !1, 'all'
         12      > JMPNZ_EX                                         ~7      ~7, ->15
         13    >   IS_EQUAL                                         ~8      !1, 'decode'
         14        BOOL                                             ~7      ~8
         15    > > JMPZ                                                     ~7, ->20
   61    16    >   INIT_FCALL                                               'urldecode'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $9      
         19        ASSIGN                                                   !0, $9
   63    20    >   ASSIGN                                                   !2, !0
   64    21      > RETURN                                                   !2
   65    22*     > RETURN                                                   null

End of function decode

End of class Stripper.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168 ms | 1412 KiB | 41 Q