3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ReformatPhoneNumber($n){ if(!preg_match('/\\d+\\-\\d+\\s\\d+/',$n))throw new Exception('Invalid phone number'); $n=str_replace(array('-',' '), '', $n); if(!in_array(strlen($n), array(7,12)))throw new Exception('Invalid phone number'); return $n; } echo ReformatPhoneNumber('-2352235 32665');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NlcVX
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'reformatphonenumber'
          1        SEND_VAL                                                 '-2352235+32665'
          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 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NlcVX
function name:  ReformatPhoneNumber
number of ops:  30
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%2F%5Cd%2B%5C-%5Cd%2B%5Cs%5Cd%2B%2F'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5        BOOL_NOT                                         ~2      $1
          6      > JMPZ                                                     ~2, ->11
          7    >   NEW                                              $3      'Exception'
          8        SEND_VAL_EX                                              'Invalid+phone+number'
          9        DO_FCALL                                      0          
         10      > THROW                                         0          $3
    4    11    >   INIT_FCALL                                               'str_replace'
         12        SEND_VAL                                                 <array>
         13        SEND_VAL                                                 ''
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $5      
         16        ASSIGN                                                   !0, $5
    5    17        INIT_FCALL                                               'in_array'
         18        STRLEN                                           ~7      !0
         19        SEND_VAL                                                 ~7
         20        SEND_VAL                                                 <array>
         21        DO_ICALL                                         $8      
         22        BOOL_NOT                                         ~9      $8
         23      > JMPZ                                                     ~9, ->28
         24    >   NEW                                              $10     'Exception'
         25        SEND_VAL_EX                                              'Invalid+phone+number'
         26        DO_FCALL                                      0          
         27      > THROW                                         0          $10
    6    28    > > RETURN                                                   !0
    7    29*     > RETURN                                                   null

End of function reformatphonenumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.76 ms | 1402 KiB | 20 Q