3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ReformatPhoneNumber($number) { if (!IsValidNumber($number)) { throw new \Exception('Invalid phone number'); } echo $number; } function IsValidNumber($number) { $validChars = array(' ', '-'); if (!is_numeric(substr($number, 0, 1)) || !is_numeric(substr($number, strlen($number) - 1, 1)) ) { return false; } $delimiterFlag = false; var_dump(explode('', $number)); return true; } echo ReformatPhoneNumber('012-345 69x');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L39K3
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'reformatphonenumber'
          1        SEND_VAL                                                 '012-345+69x'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function reformatphonenumber:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L39K3
function name:  ReformatPhoneNumber
number of ops:  12
compiled vars:  !0 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL_BY_NAME                                       'IsValidNumber'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4        BOOL_NOT                                         ~2      $1
          5      > JMPZ                                                     ~2, ->10
    6     6    >   NEW                                              $3      'Exception'
          7        SEND_VAL_EX                                              'Invalid+phone+number'
          8        DO_FCALL                                      0          
          9      > THROW                                         0          $3
    9    10    >   ECHO                                                     !0
   10    11      > RETURN                                                   null

End of function reformatphonenumber

Function isvalidnumber:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 12, Position 2 = 24
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 26
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/L39K3
function name:  IsValidNumber
number of ops:  36
compiled vars:  !0 = $number, !1 = $validChars, !2 = $delimiterFlag
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        ASSIGN                                                   !1, <array>
   16     2        INIT_FCALL                                               'is_numeric'
          3        INIT_FCALL                                               'substr'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 0
          6        SEND_VAL                                                 1
          7        DO_ICALL                                         $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                         $5      
         10        BOOL_NOT                                         ~6      $5
         11      > JMPNZ_EX                                         ~6      ~6, ->24
   17    12    >   INIT_FCALL                                               'is_numeric'
         13        INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !0
         15        STRLEN                                           ~7      !0
         16        SUB                                              ~8      ~7, 1
         17        SEND_VAL                                                 ~8
         18        SEND_VAL                                                 1
         19        DO_ICALL                                         $9      
         20        SEND_VAR                                                 $9
         21        DO_ICALL                                         $10     
         22        BOOL_NOT                                         ~11     $10
         23        BOOL                                             ~6      ~11
         24    > > JMPZ                                                     ~6, ->26
   19    25    > > RETURN                                                   <false>
   22    26    >   ASSIGN                                                   !2, <false>
   24    27        INIT_FCALL                                               'var_dump'
         28        INIT_FCALL                                               'explode'
         29        SEND_VAL                                                 ''
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                         $13     
         32        SEND_VAR                                                 $13
         33        DO_ICALL                                                 
   26    34      > RETURN                                                   <true>
   27    35*     > RETURN                                                   null

End of function isvalidnumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.42 ms | 948 KiB | 23 Q