3v4l.org

run code in 300+ PHP versions simultaneously
<?php function html_asciify(string $utf8String): string { $iterator = IntlBreakIterator::createCodePointInstance(); $iterator->setText($utf8String); $result = ''; foreach ($iterator as $pos) { if ($pos === 0) { continue; } $codePoint = $iterator->getLastCodePoint(); $result .= $codePoint <= 127 ? chr($codePoint) : '&#x' . dechex($codePoint) . ';'; } return $result; } $result = html_asciify("aaaååddd仕事bbbb\x80aaaa"); var_dump($result, html_entity_decode($result));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mJXhQ
function name:  (null)
number of ops:  12
compiled vars:  !0 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_FCALL                                               'html_asciify'
          1        SEND_VAL                                                 'aaa%C3%A5%C3%A5ddd%E4%BB%95%E4%BA%8Bbbbb%80aaaa'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   27     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !0
          6        INIT_FCALL                                               'html_entity_decode'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $3      
          9        SEND_VAR                                                 $3
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function html_asciify:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 31
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 31
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/mJXhQ
function name:  html_asciify
number of ops:  36
compiled vars:  !0 = $utf8String, !1 = $iterator, !2 = $result, !3 = $pos, !4 = $codePoint
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_STATIC_METHOD_CALL                                  'IntlBreakIterator', 'createCodePointInstance'
          2        DO_FCALL                                      0  $5      
          3        ASSIGN                                                   !1, $5
    6     4        INIT_METHOD_CALL                                         !1, 'setText'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
    8     7        ASSIGN                                                   !2, ''
   10     8      > FE_RESET_R                                       $9      !1, ->31
          9    > > FE_FETCH_R                                               $9, !3, ->31
   11    10    >   IS_IDENTICAL                                             !3, 0
         11      > JMPZ                                                     ~10, ->13
   12    12    > > JMP                                                      ->9
   15    13    >   INIT_METHOD_CALL                                         !1, 'getLastCodePoint'
         14        DO_FCALL                                      0  $11     
         15        ASSIGN                                                   !4, $11
   17    16        IS_SMALLER_OR_EQUAL                                      !4, 127
         17      > JMPZ                                                     ~13, ->23
   18    18    >   INIT_FCALL                                               'chr'
         19        SEND_VAR                                                 !4
         20        DO_ICALL                                         $14     
         21        QM_ASSIGN                                        ~15     $14
         22      > JMP                                                      ->29
   19    23    >   INIT_FCALL                                               'dechex'
         24        SEND_VAR                                                 !4
         25        DO_ICALL                                         $16     
         26        CONCAT                                           ~17     '%26%23x', $16
         27        CONCAT                                           ~18     ~17, '%3B'
         28        QM_ASSIGN                                        ~15     ~18
         29    >   ASSIGN_OP                                     8          !2, ~15
   10    30      > JMP                                                      ->9
         31    >   FE_FREE                                                  $9
   22    32        VERIFY_RETURN_TYPE                                       !2
         33      > RETURN                                                   !2
   23    34*       VERIFY_RETURN_TYPE                                       
         35*     > RETURN                                                   null

End of function html_asciify

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.57 ms | 1010 KiB | 18 Q