3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ReformatPhoneNumber($number) { if (preg_match('/^(\d[ -]?){7,12}$/', $number)) return str_replace(array(' ','-'), '', $number); throw new Exception('Invalid phone number'); } echo ReformatPhoneNumber('012-345 67');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B3apG
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                                                 '012-345+67'
          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 = 12
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/B3apG
function name:  ReformatPhoneNumber
number of ops:  17
compiled vars:  !0 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%2F%5E%28%5Cd%5B+-%5D%3F%29%7B7%2C12%7D%24%2F'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > JMPZ                                                     $1, ->12
    6     6    >   INIT_FCALL                                               'str_replace'
          7        SEND_VAL                                                 <array>
          8        SEND_VAL                                                 ''
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $2      
         11      > RETURN                                                   $2
    7    12    >   NEW                                              $3      'Exception'
         13        SEND_VAL_EX                                              'Invalid+phone+number'
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $3
    8    16*     > RETURN                                                   null

End of function reformatphonenumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.83 ms | 1398 KiB | 18 Q