3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isSpam($comment) { // Pattern to match common phrases and links $pattern = '/(Like or Not\?|Check:)\s*(https?:\/\/[^\s]+)/i'; // Check if the pattern matches if (preg_match($pattern, $comment)) { return true; } // Known spam phrases (can be expanded) $knownSpam = [ "Like or Not? Check:", ]; // Calculate similarity with known spam phrases foreach ($knownSpam as $spam) { if (similar_text($spam, substr($comment, 0, strlen($spam))) / strlen($spam) > 0.8) { return true; } } return false; } echo isSpam('like or not');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pc1g7
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'isspam'
          1        SEND_VAL                                                 'like+or+not'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function isspam:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 28
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 28
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/pc1g7
function name:  isSpam
number of ops:  31
compiled vars:  !0 = $comment, !1 = $pattern, !2 = $knownSpam, !3 = $spam
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, '%2F%28Like+or+Not%5C%3F%7CCheck%3A%29%5Cs%2A%28https%3F%3A%5C%2F%5C%2F%5B%5E%5Cs%5D%2B%29%2Fi'
    8     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6      > JMPZ                                                     $5, ->8
    9     7    > > RETURN                                                   <true>
   13     8    >   ASSIGN                                                   !2, <array>
   18     9      > FE_RESET_R                                       $7      !2, ->28
         10    > > FE_FETCH_R                                               $7, !3, ->28
   19    11    >   INIT_FCALL                                               'similar_text'
         12        SEND_VAR                                                 !3
         13        INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 0
         16        STRLEN                                           ~8      !3
         17        SEND_VAL                                                 ~8
         18        DO_ICALL                                         $9      
         19        SEND_VAR                                                 $9
         20        DO_ICALL                                         $10     
         21        STRLEN                                           ~11     !3
         22        DIV                                              ~12     $10, ~11
         23        IS_SMALLER                                               0.8, ~12
         24      > JMPZ                                                     ~13, ->27
   20    25    >   FE_FREE                                                  $7
         26      > RETURN                                                   <true>
   18    27    > > JMP                                                      ->10
         28    >   FE_FREE                                                  $7
   24    29      > RETURN                                                   <false>
   25    30*     > RETURN                                                   null

End of function isspam

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.19 ms | 1435 KiB | 17 Q