3v4l.org

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

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

End of function trygetphonenumber

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.84 ms | 1403 KiB | 19 Q