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; } 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/guGM3
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     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/guGM3
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/guGM3
function name:  IsValidNumber
number of ops:  28
compiled vars:  !0 = $number, !1 = $validChars
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                                         $3      
          8        SEND_VAR                                                 $3
          9        DO_ICALL                                         $4      
         10        BOOL_NOT                                         ~5      $4
         11      > JMPNZ_EX                                         ~5      ~5, ->24
   17    12    >   INIT_FCALL                                               'is_numeric'
         13        INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !0
         15        STRLEN                                           ~6      !0
         16        SUB                                              ~7      ~6, 1
         17        SEND_VAL                                                 ~7
         18        SEND_VAL                                                 1
         19        DO_ICALL                                         $8      
         20        SEND_VAR                                                 $8
         21        DO_ICALL                                         $9      
         22        BOOL_NOT                                         ~10     $9
         23        BOOL                                             ~5      ~10
         24    > > JMPZ                                                     ~5, ->26
   19    25    > > RETURN                                                   <false>
   22    26    > > RETURN                                                   <true>
   23    27*     > RETURN                                                   null

End of function isvalidnumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.64 ms | 1394 KiB | 18 Q