3v4l.org

run code in 300+ PHP versions simultaneously
<?php function testWordCount ($in) { $is_match = preg_match('/^(\b[^\s]+\s*){2,40}$/', $in); return (boolean)$is_match; } echo "1 words returns:\r\n"; var_dump(testWordCount('1')); echo "\r\n"; echo "3 words returns:\r\n"; var_dump(testWordCount('1 2 3')); echo "\r\n"; echo "40 words returns:\r\n"; var_dump(testWordCount('1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40')); echo "\r\n"; echo "41 words returns:\r\n"; var_dump(testWordCount('1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41')); echo "\r\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZniDM
function name:  (null)
number of ops:  33
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ECHO                                                     '1+words+returns%3A%0D%0A'
    8     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'testwordcount'
          3        SEND_VAL                                                 '1'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
    9     7        ECHO                                                     '%0D%0A'
   11     8        ECHO                                                     '3+words+returns%3A%0D%0A'
   12     9        INIT_FCALL                                               'var_dump'
         10        INIT_FCALL                                               'testwordcount'
         11        SEND_VAL                                                 '1+2+3'
         12        DO_FCALL                                      0  $2      
         13        SEND_VAR                                                 $2
         14        DO_ICALL                                                 
   13    15        ECHO                                                     '%0D%0A'
   15    16        ECHO                                                     '40+words+returns%3A%0D%0A'
   16    17        INIT_FCALL                                               'var_dump'
         18        INIT_FCALL                                               'testwordcount'
         19        SEND_VAL                                                 '1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40'
         20        DO_FCALL                                      0  $4      
         21        SEND_VAR                                                 $4
         22        DO_ICALL                                                 
   17    23        ECHO                                                     '%0D%0A'
   19    24        ECHO                                                     '41+words+returns%3A%0D%0A'
   20    25        INIT_FCALL                                               'var_dump'
         26        INIT_FCALL                                               'testwordcount'
         27        SEND_VAL                                                 '1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41'
         28        DO_FCALL                                      0  $6      
         29        SEND_VAR                                                 $6
         30        DO_ICALL                                                 
   21    31        ECHO                                                     '%0D%0A'
         32      > RETURN                                                   1

Function testwordcount:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZniDM
function name:  testWordCount
number of ops:  9
compiled vars:  !0 = $in, !1 = $is_match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%2F%5E%28%5Cb%5B%5E%5Cs%5D%2B%5Cs%2A%29%7B2%2C40%7D%24%2F'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !1, $2
    4     6        BOOL                                             ~4      !1
          7      > RETURN                                                   ~4
    5     8*     > RETURN                                                   null

End of function testwordcount

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
274.87 ms | 1403 KiB | 22 Q