3v4l.org

run code in 300+ PHP versions simultaneously
<?php function countWords($sentence) { return count(preg_split('~\s+~', $sentence)); } echo countWords("my name is john"); echo countWords("my name \n\r is john"); echo countWords("my name \n is john"); echo countWords("my name \n\n\r is john"); echo countWords("my \n name is john");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/48q6N
function name:  (null)
number of ops:  21
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'countwords'
          1        SEND_VAL                                                 'my+name+is+john'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   10     4        INIT_FCALL                                               'countwords'
          5        SEND_VAL                                                 'my+name+%0A%0D+is+john'
          6        DO_FCALL                                      0  $1      
          7        ECHO                                                     $1
   11     8        INIT_FCALL                                               'countwords'
          9        SEND_VAL                                                 'my+name+%0A+is+john'
         10        DO_FCALL                                      0  $2      
         11        ECHO                                                     $2
   12    12        INIT_FCALL                                               'countwords'
         13        SEND_VAL                                                 'my+name+%0A%0A%0D+is+john'
         14        DO_FCALL                                      0  $3      
         15        ECHO                                                     $3
   13    16        INIT_FCALL                                               'countwords'
         17        SEND_VAL                                                 'my+%0A+name+is+john'
         18        DO_FCALL                                      0  $4      
         19        ECHO                                                     $4
         20      > RETURN                                                   1

Function countwords:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/48q6N
function name:  countWords
number of ops:  8
compiled vars:  !0 = $sentence
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'preg_split'
          2        SEND_VAL                                                 '%7E%5Cs%2B%7E'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5        COUNT                                            ~2      $1
          6      > RETURN                                                   ~2
    7     7*     > RETURN                                                   null

End of function countwords

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.76 ms | 1390 KiB | 20 Q