3v4l.org

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

End of function reformatphonenumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.68 ms | 1399 KiB | 18 Q