3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function test($input) { $output = htmlspecialchars($input, ENT_QUOTES, 'UTF-8'); $code = str_replace('%', '\\x', rawurlencode($input)); if (validate_utf8($input)) { echo "【{$output}】({$code}) は有効なUTF-8シーケンスです。\n"; } else { echo "({$code}) は無効なUTF-8シーケンスです。\n"; } } test("☝( ◠‿◠ )☝"); test("ゔ〲〰"); test("\x0a\x92\xff"); // てきとー test("\xef\xbb\xbf"); // BOMだっけ test(""); // 空文字列 echo "\n"; test("\x2f"); // スラッシュ(1バイト) test("\xc0\xaf"); // スラッシュ(冗長2バイト) test("\xe0\x80\xaf"); // スラッシュ(冗長3バイト) test("\xf0\x80\x80\xaf"); // スラッシュ(冗長4バイト)
based on oXOEL
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4NNW0
function name:  (null)
number of ops:  30
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  16     1        INIT_FCALL                                               'test'
         2        SEND_VAL                                                 '%E2%98%9D%28+%E2%97%A0%E2%80%BF%E2%97%A0+%29%E2%98%9D'
         3        DO_FCALL                                      0          
  17     4        INIT_FCALL                                               'test'
         5        SEND_VAL                                                 '%E3%82%94%E3%80%B2%E3%80%B0'
         6        DO_FCALL                                      0          
  18     7        INIT_FCALL                                               'test'
         8        SEND_VAL                                                 '%0A%92%FF'
         9        DO_FCALL                                      0          
  19    10        INIT_FCALL                                               'test'
        11        SEND_VAL                                                 '%EF%BB%BF'
        12        DO_FCALL                                      0          
  20    13        INIT_FCALL                                               'test'
        14        SEND_VAL                                                 ''
        15        DO_FCALL                                      0          
  22    16        ECHO                                                     '%0A'
  24    17        INIT_FCALL                                               'test'
        18        SEND_VAL                                                 '%2F'
        19        DO_FCALL                                      0          
  25    20        INIT_FCALL                                               'test'
        21        SEND_VAL                                                 '%C0%AF'
        22        DO_FCALL                                      0          
  26    23        INIT_FCALL                                               'test'
        24        SEND_VAL                                                 '%E0%80%AF'
        25        DO_FCALL                                      0          
  27    26        INIT_FCALL                                               'test'
        27        SEND_VAL                                                 '%F0%80%80%AF'
        28        DO_FCALL                                      0          
        29      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 27
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4NNW0
function name:  test
number of ops:  32
compiled vars:  !0 = $input, !1 = $output, !2 = $code
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   RECV                                             !0      
   5     1        INIT_FCALL                                               'htmlspecialchars'
         2        SEND_VAR                                                 !0
         3        SEND_VAL                                                 3
         4        SEND_VAL                                                 'UTF-8'
         5        DO_ICALL                                         $3      
         6        ASSIGN                                                   !1, $3
   6     7        INIT_FCALL                                               'str_replace'
         8        SEND_VAL                                                 '%25'
         9        SEND_VAL                                                 '%5Cx'
        10        INIT_FCALL                                               'rawurlencode'
        11        SEND_VAR                                                 !0
        12        DO_ICALL                                         $5      
        13        SEND_VAR                                                 $5
        14        DO_ICALL                                         $6      
        15        ASSIGN                                                   !2, $6
   8    16        INIT_FCALL_BY_NAME                                       'validate_utf8'
        17        SEND_VAR_EX                                              !0
        18        DO_FCALL                                      0  $8      
        19      > JMPZ                                                     $8, ->27
   9    20    >   ROPE_INIT                                     5  ~10     '%E3%80%90'
        21        ROPE_ADD                                      1  ~10     ~10, !1
        22        ROPE_ADD                                      2  ~10     ~10, '%E3%80%91%28'
        23        ROPE_ADD                                      3  ~10     ~10, !2
        24        ROPE_END                                      4  ~9      ~10, '%29+%E3%81%AF%E6%9C%89%E5%8A%B9%E3%81%AAUTF-8%E3%82%B7%E3%83%BC%E3%82%B1%E3%83%B3%E3%82%B9%E3%81%A7%E3%81%99%E3%80%82%0A'
        25        ECHO                                                     ~9
        26      > JMP                                                      ->31
  11    27    >   ROPE_INIT                                     3  ~14     '%28'
        28        ROPE_ADD                                      1  ~14     ~14, !2
        29        ROPE_END                                      2  ~13     ~14, '%29+%E3%81%AF%E7%84%A1%E5%8A%B9%E3%81%AAUTF-8%E3%82%B7%E3%83%BC%E3%82%B1%E3%83%B3%E3%82%B9%E3%81%A7%E3%81%99%E3%80%82%0A'
        30        ECHO                                                     ~13
  14    31    > > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 7.3.0