3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo "strlen ГРАЙ: " . strlen('ГРАЙ') . PHP_EOL; $mask = function ($name) { $length = strlen($name); return $name[0] . str_repeat('*', $length - 2) . $name[$length - 1]; }; echo "single-byte mask: " . $mask('ГРАЙ') . PHP_EOL; $grapheme_mask = function ($name) { $length = grapheme_strlen($name); return grapheme_substr($name, 0, 1) . str_repeat('*', $length - 2) . grapheme_substr($name, -1, 1); }; echo "grapheme mask: " . $grapheme_mask('ГРАЙ') . PHP_EOL; $mb_mask = function ($name) { $length = mb_strlen($name); return mb_substr($name, 0, 1) . str_repeat('*', $length - 2) . mb_substr($name, -1, 1); }; echo "mb mask: " . $mb_mask('ГРАЙ') . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mIWga
function name:  (null)
number of ops:  26
compiled vars:  !0 = $mask, !1 = $grapheme_mask, !2 = $mb_mask
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ECHO                                                     'strlen+%D0%93%D0%A0%D0%90%D0%99%3A+8%0A'
    5     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FmIWga%3A5%240'
          2        ASSIGN                                                   !0, ~3
    6     3        INIT_DYNAMIC_CALL                                        !0
          4        SEND_VAL_EX                                              '%D0%93%D0%A0%D0%90%D0%99'
          5        DO_FCALL                                      0  $5      
          6        CONCAT                                           ~6      'single-byte+mask%3A+', $5
          7        CONCAT                                           ~7      ~6, '%0A'
          8        ECHO                                                     ~7
    8     9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FmIWga%3A8%241'
         10        ASSIGN                                                   !1, ~8
    9    11        INIT_DYNAMIC_CALL                                        !1
         12        SEND_VAL_EX                                              '%D0%93%D0%A0%D0%90%D0%99'
         13        DO_FCALL                                      0  $10     
         14        CONCAT                                           ~11     'grapheme+mask%3A+', $10
         15        CONCAT                                           ~12     ~11, '%0A'
         16        ECHO                                                     ~12
   11    17        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FmIWga%3A11%242'
         18        ASSIGN                                                   !2, ~13
   12    19        INIT_DYNAMIC_CALL                                        !2
         20        SEND_VAL_EX                                              '%D0%93%D0%A0%D0%90%D0%99'
         21        DO_FCALL                                      0  $15     
         22        CONCAT                                           ~16     'mb+mask%3A+', $15
         23        CONCAT                                           ~17     ~16, '%0A'
         24        ECHO                                                     ~17
   13    25      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FmIWga%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mIWga
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $name, !1 = $length
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        STRLEN                                           ~2      !0
          2        ASSIGN                                                   !1, ~2
          3        FETCH_DIM_R                                      ~4      !0, 0
          4        INIT_FCALL                                               'str_repeat'
          5        SEND_VAL                                                 '%2A'
          6        SUB                                              ~5      !1, 2
          7        SEND_VAL                                                 ~5
          8        DO_ICALL                                         $6      
          9        CONCAT                                           ~7      ~4, $6
         10        SUB                                              ~8      !1, 1
         11        FETCH_DIM_R                                      ~9      !0, ~8
         12        CONCAT                                           ~10     ~7, ~9
         13      > RETURN                                                   ~10
         14*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FmIWga%3A5%240

Function %00%7Bclosure%7D%2Fin%2FmIWga%3A8%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mIWga
function name:  {closure}
number of ops:  24
compiled vars:  !0 = $name, !1 = $length
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        INIT_FCALL_BY_NAME                                       'grapheme_strlen'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !1, $2
          5        INIT_FCALL_BY_NAME                                       'grapheme_substr'
          6        SEND_VAR_EX                                              !0
          7        SEND_VAL_EX                                              0
          8        SEND_VAL_EX                                              1
          9        DO_FCALL                                      0  $4      
         10        INIT_FCALL                                               'str_repeat'
         11        SEND_VAL                                                 '%2A'
         12        SUB                                              ~5      !1, 2
         13        SEND_VAL                                                 ~5
         14        DO_ICALL                                         $6      
         15        CONCAT                                           ~7      $4, $6
         16        INIT_FCALL_BY_NAME                                       'grapheme_substr'
         17        SEND_VAR_EX                                              !0
         18        SEND_VAL_EX                                              -1
         19        SEND_VAL_EX                                              1
         20        DO_FCALL                                      0  $8      
         21        CONCAT                                           ~9      ~7, $8
         22      > RETURN                                                   ~9
         23*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FmIWga%3A8%241

Function %00%7Bclosure%7D%2Fin%2FmIWga%3A11%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mIWga
function name:  {closure}
number of ops:  24
compiled vars:  !0 = $name, !1 = $length
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'mb_strlen'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
          5        INIT_FCALL                                               'mb_substr'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 0
          8        SEND_VAL                                                 1
          9        DO_ICALL                                         $4      
         10        INIT_FCALL                                               'str_repeat'
         11        SEND_VAL                                                 '%2A'
         12        SUB                                              ~5      !1, 2
         13        SEND_VAL                                                 ~5
         14        DO_ICALL                                         $6      
         15        CONCAT                                           ~7      $4, $6
         16        INIT_FCALL                                               'mb_substr'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 -1
         19        SEND_VAL                                                 1
         20        DO_ICALL                                         $8      
         21        CONCAT                                           ~9      ~7, $8
         22      > RETURN                                                   ~9
         23*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FmIWga%3A11%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.51 ms | 1415 KiB | 25 Q