3v4l.org

run code in 300+ PHP versions simultaneously
<?php function tryGetPhoneNumber($input) { if (preg_match('/(?<phoneNumber>\d{3}-\d{3}-\d{4})/', $input, $match)) { return $match['phoneNumber']; } return false; } $value = tryGetPhoneNumber("I'm going to call 555-123-4567 tomorrow.", $phoneNumber); if (is_string($value)) { var_dump($value); } else { echo 'No phone number.'; }
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 = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QC3HP
function name:  (null)
number of ops:  13
compiled vars:  !0 = $value, !1 = $phoneNumber
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'trygetphonenumber'
          1        SEND_VAL                                                 'I%27m+going+to+call+555-123-4567+tomorrow.'
          2        SEND_VAR                                                 !1
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !0, $2
   10     5        TYPE_CHECK                                   64          !0
          6      > JMPZ                                                     ~4, ->11
   11     7    >   INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
         10      > JMP                                                      ->12
   13    11    >   ECHO                                                     'No+phone+number.'
   14    12    > > RETURN                                                   1

Function trygetphonenumber:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QC3HP
function name:  tryGetPhoneNumber
number of ops:  11
compiled vars:  !0 = $input, !1 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%2F%28%3F%3CphoneNumber%3E%5Cd%7B3%7D-%5Cd%7B3%7D-%5Cd%7B4%7D%29%2F'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                         $2      
          6      > JMPZ                                                     $2, ->9
    5     7    >   FETCH_DIM_R                                      ~3      !1, 'phoneNumber'
          8      > RETURN                                                   ~3
    7     9    > > RETURN                                                   <false>
    8    10*     > RETURN                                                   null

End of function trygetphonenumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.95 ms | 1399 KiB | 18 Q