3v4l.org

run code in 500+ PHP versions simultaneously
<?php function mostlyUpperInString($s, $threshold) { return preg_match_all("/\p{Lu}/u", $s) / mb_strlen($s) > $threshold; } function moreUpperThanLower($s, $threshold) { return preg_match_all("/\p{Lu}/u", $s) / preg_match_all("/\P{Lu}/u", $s) > $threshold; } $strings = [ "THE 15 SMALL BROWN FOXES JUMP INTO THE BURNING barn!", "The 15 Small Brown Foxes JUMP Into the Burning Barn!" ]; foreach ($strings as $str) { echo $str . " -> 80% mostlyUpperInString: ". (mostlyUpperInString($str, 0.8) ? "true" : "false") . PHP_EOL; echo $str . " -> 80% moreUpperThanLower: ". (moreUpperThanLower($str, 0.8) ? "true" : "false") . PHP_EOL; echo PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 29
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 29
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
Branch analysis from position: 23
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/IvqEd
function name:  (null)
number of ops:  31
compiled vars:  !0 = $strings, !1 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                       !0, <array>
   16     1      > FE_RESET_R                                           $3      !0, ->29
          2    > > FE_FETCH_R                                                   $3, !1, ->29
   17     3    >   CONCAT                                               ~4      !1, '+-%3E+80%25+mostlyUpperInString%3A+'
          4        INIT_FCALL                                                   'mostlyupperinstring'
          5        SEND_VAR                                                     !1
          6        SEND_VAL                                                     0.8
          7        DO_FCALL                                          0  $5      
          8      > JMPZ                                                         $5, ->11
          9    >   QM_ASSIGN                                            ~6      'true'
         10      > JMP                                                          ->12
         11    >   QM_ASSIGN                                            ~6      'false'
         12    >   CONCAT                                               ~7      ~4, ~6
         13        CONCAT                                               ~8      ~7, '%0A'
         14        ECHO                                                         ~8
   18    15        CONCAT                                               ~9      !1, '+-%3E+80%25+moreUpperThanLower%3A+'
         16        INIT_FCALL                                                   'moreupperthanlower'
         17        SEND_VAR                                                     !1
         18        SEND_VAL                                                     0.8
         19        DO_FCALL                                          0  $10     
         20      > JMPZ                                                         $10, ->23
         21    >   QM_ASSIGN                                            ~11     'true'
         22      > JMP                                                          ->24
         23    >   QM_ASSIGN                                            ~11     'false'
         24    >   CONCAT                                               ~12     ~9, ~11
         25        CONCAT                                               ~13     ~12, '%0A'
         26        ECHO                                                         ~13
   19    27        ECHO                                                         '%0A'
   16    28      > JMP                                                          ->2
         29    >   FE_FREE                                                      $3
   20    30      > RETURN                                                       1

Function mostlyupperinstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IvqEd
function name:  mostlyUpperInString
number of ops:  13
compiled vars:  !0 = $s, !1 = $threshold
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    4     2        INIT_FCALL                                                   'preg_match_all'
          3        SEND_VAL                                                     '%2F%5Cp%7BLu%7D%2Fu'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $2      
          6        INIT_FCALL                                                   'mb_strlen'
          7        SEND_VAR                                                     !0
          8        DO_ICALL                                             $3      
          9        DIV                                                  ~4      $2, $3
         10        IS_SMALLER                                           ~5      !1, ~4
         11      > RETURN                                                       ~5
    5    12*     > RETURN                                                       null

End of function mostlyupperinstring

Function moreupperthanlower:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IvqEd
function name:  moreUpperThanLower
number of ops:  14
compiled vars:  !0 = $s, !1 = $threshold
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    8     2        INIT_FCALL                                                   'preg_match_all'
          3        SEND_VAL                                                     '%2F%5Cp%7BLu%7D%2Fu'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $2      
          6        INIT_FCALL                                                   'preg_match_all'
          7        SEND_VAL                                                     '%2F%5CP%7BLu%7D%2Fu'
          8        SEND_VAR                                                     !0
          9        DO_ICALL                                             $3      
         10        DIV                                                  ~4      $2, $3
         11        IS_SMALLER                                           ~5      !1, ~4
         12      > RETURN                                                       ~5
    9    13*     > RETURN                                                       null

End of function moreupperthanlower

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.32 ms | 1993 KiB | 17 Q