3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mask_email($email, $masks = 5) { $array = explode("@", $email); $string_length = strlen($array[0]); if ($string_length < $masks) $masks = $string_length; $result = substr($array[0], 0, -$masks) . str_repeat('*', $masks); return $result."@".$array[1]; } echo mask_email("tesasdasdasdt@test.com")."\n"; echo mask_email("longeremail@test.com")."\n"; echo mask_email("longeremail@test.com", 2)."\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Jbmga
function name:  (null)
number of ops:  17
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'mask_email'
          1        SEND_VAL                                                 'tesasdasdasdt%40test.com'
          2        DO_FCALL                                      0  $0      
          3        CONCAT                                           ~1      $0, '%0A'
          4        ECHO                                                     ~1
   13     5        INIT_FCALL                                               'mask_email'
          6        SEND_VAL                                                 'longeremail%40test.com'
          7        DO_FCALL                                      0  $2      
          8        CONCAT                                           ~3      $2, '%0A'
          9        ECHO                                                     ~3
   14    10        INIT_FCALL                                               'mask_email'
         11        SEND_VAL                                                 'longeremail%40test.com'
         12        SEND_VAL                                                 2
         13        DO_FCALL                                      0  $4      
         14        CONCAT                                           ~5      $4, '%0A'
         15        ECHO                                                     ~5
         16      > RETURN                                                   1

Function mask_email:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/Jbmga
function name:  mask_email
number of ops:  31
compiled vars:  !0 = $email, !1 = $masks, !2 = $array, !3 = $string_length, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      5
    4     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%40'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !2, $5
    5     7        FETCH_DIM_R                                      ~7      !2, 0
          8        STRLEN                                           ~8      ~7
          9        ASSIGN                                                   !3, ~8
    6    10        IS_SMALLER                                               !3, !1
         11      > JMPZ                                                     ~10, ->13
    7    12    >   ASSIGN                                                   !1, !3
    8    13    >   INIT_FCALL                                               'substr'
         14        FETCH_DIM_R                                      ~12     !2, 0
         15        SEND_VAL                                                 ~12
         16        SEND_VAL                                                 0
         17        MUL                                              ~13     !1, -1
         18        SEND_VAL                                                 ~13
         19        DO_ICALL                                         $14     
         20        INIT_FCALL                                               'str_repeat'
         21        SEND_VAL                                                 '%2A'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                         $15     
         24        CONCAT                                           ~16     $14, $15
         25        ASSIGN                                                   !4, ~16
    9    26        CONCAT                                           ~18     !4, '%40'
         27        FETCH_DIM_R                                      ~19     !2, 1
         28        CONCAT                                           ~20     ~18, ~19
         29      > RETURN                                                   ~20
   10    30*     > RETURN                                                   null

End of function mask_email

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.38 ms | 1403 KiB | 22 Q