3v4l.org

run code in 300+ PHP versions simultaneously
<?php function checkOperation(string $operation): ?string { if (!preg_match('/^\d+([a-zA-Z]+)\+\d+([a-zA-Z]+)$/', $operation, $matches)) { return null; } if (array_count_values(str_split($matches[1])) != array_count_values(str_split($matches[2]))) { return null; } return $operation; } var_dump(checkOperation('5p+3p')); echo PHP_EOL; var_dump(checkOperation('5AB+3AB')); echo PHP_EOL; var_dump(checkOperation('5AB+3BA')); echo PHP_EOL; var_dump(checkOperation('5p+3q'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iS8Ih
function name:  (null)
number of ops:  28
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'checkoperation'
          2        SEND_VAL                                                 '5p%2B3p'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6        ECHO                                                     '%0A'
   16     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'checkoperation'
          9        SEND_VAL                                                 '5AB%2B3AB'
         10        DO_FCALL                                      0  $2      
         11        SEND_VAR                                                 $2
         12        DO_ICALL                                                 
         13        ECHO                                                     '%0A'
   17    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'checkoperation'
         16        SEND_VAL                                                 '5AB%2B3BA'
         17        DO_FCALL                                      0  $4      
         18        SEND_VAR                                                 $4
         19        DO_ICALL                                                 
         20        ECHO                                                     '%0A'
   18    21        INIT_FCALL                                               'var_dump'
         22        INIT_FCALL                                               'checkoperation'
         23        SEND_VAL                                                 '5p%2B3q'
         24        DO_FCALL                                      0  $6      
         25        SEND_VAR                                                 $6
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Function checkoperation:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
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
filename:       /in/iS8Ih
function name:  checkOperation
number of ops:  30
compiled vars:  !0 = $operation, !1 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%2F%5E%5Cd%2B%28%5Ba-zA-Z%5D%2B%29%5C%2B%5Cd%2B%28%5Ba-zA-Z%5D%2B%29%24%2F'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                         $2      
          6        BOOL_NOT                                         ~3      $2
          7      > JMPZ                                                     ~3, ->9
    5     8    > > RETURN                                                   null
    8     9    >   INIT_FCALL                                               'array_count_values'
         10        INIT_FCALL                                               'str_split'
         11        FETCH_DIM_R                                      ~4      !1, 1
         12        SEND_VAL                                                 ~4
         13        DO_ICALL                                         $5      
         14        SEND_VAR                                                 $5
         15        DO_ICALL                                         $6      
         16        INIT_FCALL                                               'array_count_values'
         17        INIT_FCALL                                               'str_split'
         18        FETCH_DIM_R                                      ~7      !1, 2
         19        SEND_VAL                                                 ~7
         20        DO_ICALL                                         $8      
         21        SEND_VAR                                                 $8
         22        DO_ICALL                                         $9      
         23        IS_NOT_EQUAL                                             $6, $9
         24      > JMPZ                                                     ~10, ->26
    9    25    > > RETURN                                                   null
   12    26    >   VERIFY_RETURN_TYPE                                       !0
         27      > RETURN                                                   !0
   13    28*       VERIFY_RETURN_TYPE                                       
         29*     > RETURN                                                   null

End of function checkoperation

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.55 ms | 1016 KiB | 21 Q