3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); function countOccurrence(int $number, int $digit){ $result = 0; while ($number > 0){ $lastDigit = $number % 10; if($lastDigit === $digit){ $result++; } $number = ($number - $lastDigit)/10; } return $result; } echo countOccurrence(1111,1); // this is fine :) echo PHP_EOL; // just a line-break echo countOccurrence(1111,'1'); // this will throw an error with strict_types=1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QPYAt
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'countoccurrence'
          1        SEND_VAL                                                 1111
          2        SEND_VAL                                                 1
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
   18     5        ECHO                                                     '%0A'
   19     6        INIT_FCALL                                               'countoccurrence'
          7        SEND_VAL                                                 1111
          8        SEND_VAL                                                 '1'
          9        DO_FCALL                                      0  $1      
         10        ECHO                                                     $1
         11      > RETURN                                                   1

Function countoccurrence:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 4
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 4
Branch analysis from position: 14
Branch analysis from position: 4
Branch analysis from position: 9
filename:       /in/QPYAt
function name:  countOccurrence
number of ops:  16
compiled vars:  !0 = $number, !1 = $digit, !2 = $result, !3 = $lastDigit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        ASSIGN                                                   !2, 0
    7     3      > JMP                                                      ->12
    8     4    >   MOD                                              ~5      !0, 10
          5        ASSIGN                                                   !3, ~5
    9     6        IS_IDENTICAL                                             !3, !1
          7      > JMPZ                                                     ~7, ->9
   10     8    >   PRE_INC                                                  !2
   12     9    >   SUB                                              ~9      !0, !3
         10        DIV                                              ~10     ~9, 10
         11        ASSIGN                                                   !0, ~10
    7    12    >   IS_SMALLER                                               0, !0
         13      > JMPNZ                                                    ~12, ->4
   14    14    > > RETURN                                                   !2
   15    15*     > RETURN                                                   null

End of function countoccurrence

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.79 ms | 999 KiB | 15 Q