3v4l.org

run code in 300+ PHP versions simultaneously
<?php function wp_total_pages( $total_items, $per_page ) { $remainder = $total_items % $per_page; if ( $remainder ) { $total_items += $per_page - $remainder; } return $total_items / $per_page; } $input_sets = [ [506, 10], [505, 10], [504, 10], [500, 9.5], [500, 9], [35478743512, 15], [PHP_INT_MAX, 20], [PHP_INT_MAX + 250, 20], ]; foreach ($input_sets as list($a, $b)) { echo PHP_EOL, '=================================================', PHP_EOL; echo 'Given the following inputs:', PHP_EOL; var_dump($a, $b); $over = $a % $b; $over = ($over > 0) ? 1 : 0; echo PHP_EOL, 'The results will be:', PHP_EOL; echo 'ceil: ', var_dump(ceil($a/$b)); echo 'round + ceil: ', var_dump(round(ceil($a/$b))); echo 'wp_total_pages: ', var_dump(wp_total_pages($a, $b)); try { if (function_exists('intdiv')) { echo 'intdiv: ', var_dump($over + intdiv($a, $b)); } else { echo 'intdiv function not available', PHP_EOL; } } catch (Error $e) { echo 'intdiv: ', $e->getMessage(), PHP_EOL; } try { echo 'bcdiv: ', var_dump($over + bcdiv($a, $b)); } catch (Error $e) { echo 'bcdiv: ', $e->getMessage(), PHP_EOL; } echo PHP_EOL, 'And the results with an int cast added will be:', PHP_EOL; echo 'ceil: ', var_dump((int) ceil($a/$b)); echo 'round + ceil: ', var_dump((int) round(ceil($a/$b))); echo 'wp_total_pages: ', var_dump((int) wp_total_pages($a, $b)); try { if (function_exists('intdiv')) { echo 'intdiv: ', var_dump((int)($over + intdiv($a, $b))); } else { echo 'intdiv function not available', PHP_EOL; } } catch (Error $e) { echo 'intdiv: ', $e->getMessage(), PHP_EOL; } try { echo 'bcdiv: ', var_dump((int) ($over + bcdiv($a, $b))); } catch (Error $e) { echo 'bcdiv: ', $e->getMessage(), PHP_EOL; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 179
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 179
Branch analysis from position: 3
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
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 73
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 82
Branch analysis from position: 82
1 jumps found. (Code = 42) Position 1 = 99
Branch analysis from position: 99
2 jumps found. (Code = 43) Position 1 = 139, Position 2 = 151
Branch analysis from position: 139
1 jumps found. (Code = 42) Position 1 = 153
Branch analysis from position: 153
1 jumps found. (Code = 42) Position 1 = 160
Branch analysis from position: 160
1 jumps found. (Code = 42) Position 1 = 178
Branch analysis from position: 178
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 151
1 jumps found. (Code = 42) Position 1 = 160
Branch analysis from position: 160
Branch analysis from position: 73
1 jumps found. (Code = 42) Position 1 = 82
Branch analysis from position: 82
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 73
Branch analysis from position: 62
Branch analysis from position: 73
Branch analysis from position: 179
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 179
Found catch point at position: 76
Branch analysis from position: 76
2 jumps found. (Code = 107) Position 1 = 77, Position 2 = -2
Branch analysis from position: 77
1 jumps found. (Code = 42) Position 1 = 99
Branch analysis from position: 99
Found catch point at position: 93
Branch analysis from position: 93
2 jumps found. (Code = 107) Position 1 = 94, Position 2 = -2
Branch analysis from position: 94
2 jumps found. (Code = 43) Position 1 = 139, Position 2 = 151
Branch analysis from position: 139
Branch analysis from position: 151
Found catch point at position: 154
Branch analysis from position: 154
2 jumps found. (Code = 107) Position 1 = 155, Position 2 = -2
Branch analysis from position: 155
1 jumps found. (Code = 42) Position 1 = 178
Branch analysis from position: 178
Found catch point at position: 172
Branch analysis from position: 172
2 jumps found. (Code = 107) Position 1 = 173, Position 2 = -2
Branch analysis from position: 173
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
filename:       /in/V6jdD
function name:  (null)
number of ops:  181
compiled vars:  !0 = $input_sets, !1 = $a, !2 = $b, !3 = $over, !4 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, <array>
   22     1      > FE_RESET_R                                       $6      !0, ->179
          2    > > FE_FETCH_R                                               $6, $7, ->179
          3    >   FETCH_LIST_R                                     $8      $7, 0
          4        ASSIGN                                                   !1, $8
          5        FETCH_LIST_R                                     $10     $7, 1
          6        ASSIGN                                                   !2, $10
          7        FREE                                                     $7
   23     8        ECHO                                                     '%0A'
          9        ECHO                                                     '%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D'
         10        ECHO                                                     '%0A'
   24    11        ECHO                                                     'Given+the+following+inputs%3A'
         12        ECHO                                                     '%0A'
   25    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !1
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                                 
   26    17        MOD                                              ~13     !1, !2
         18        ASSIGN                                                   !3, ~13
   27    19        IS_SMALLER                                               0, !3
         20      > JMPZ                                                     ~15, ->23
         21    >   QM_ASSIGN                                        ~16     1
         22      > JMP                                                      ->24
         23    >   QM_ASSIGN                                        ~16     0
         24    >   ASSIGN                                                   !3, ~16
   29    25        ECHO                                                     '%0A'
         26        ECHO                                                     'The+results+will+be%3A'
         27        ECHO                                                     '%0A'
   30    28        ECHO                                                     'ceil%3A+++++++++++'
         29        INIT_FCALL                                               'var_dump'
         30        INIT_FCALL                                               'ceil'
         31        DIV                                              ~18     !1, !2
         32        SEND_VAL                                                 ~18
         33        DO_ICALL                                         $19     
         34        SEND_VAR                                                 $19
         35        DO_ICALL                                         $20     
         36        ECHO                                                     $20
   31    37        ECHO                                                     'round+%2B+ceil%3A+++'
         38        INIT_FCALL                                               'var_dump'
         39        INIT_FCALL                                               'round'
         40        INIT_FCALL                                               'ceil'
         41        DIV                                              ~21     !1, !2
         42        SEND_VAL                                                 ~21
         43        DO_ICALL                                         $22     
         44        SEND_VAR                                                 $22
         45        DO_ICALL                                         $23     
         46        SEND_VAR                                                 $23
         47        DO_ICALL                                         $24     
         48        ECHO                                                     $24
   32    49        ECHO                                                     'wp_total_pages%3A+'
         50        INIT_FCALL                                               'var_dump'
         51        INIT_FCALL                                               'wp_total_pages'
         52        SEND_VAR                                                 !1
         53        SEND_VAR                                                 !2
         54        DO_FCALL                                      0  $25     
         55        SEND_VAR                                                 $25
         56        DO_ICALL                                         $26     
         57        ECHO                                                     $26
   34    58        INIT_FCALL                                               'function_exists'
         59        SEND_VAL                                                 'intdiv'
         60        DO_ICALL                                         $27     
         61      > JMPZ                                                     $27, ->73
   35    62    >   ECHO                                                     'intdiv%3A+++++++++'
         63        INIT_FCALL                                               'var_dump'
         64        INIT_FCALL                                               'intdiv'
         65        SEND_VAR                                                 !1
         66        SEND_VAR                                                 !2
         67        DO_ICALL                                         $28     
         68        ADD                                              ~29     !3, $28
         69        SEND_VAL                                                 ~29
         70        DO_ICALL                                         $30     
         71        ECHO                                                     $30
   34    72      > JMP                                                      ->75
   37    73    >   ECHO                                                     'intdiv+function+not+available'
         74        ECHO                                                     '%0A'
         75    > > JMP                                                      ->82
   39    76  E > > CATCH                                       last         'Error'
   40    77    >   ECHO                                                     'intdiv%3A+++++++++'
         78        INIT_METHOD_CALL                                         !4, 'getMessage'
         79        DO_FCALL                                      0  $31     
         80        ECHO                                                     $31
         81        ECHO                                                     '%0A'
   43    82    >   ECHO                                                     'bcdiv%3A++++++++++'
         83        INIT_FCALL                                               'var_dump'
         84        INIT_FCALL_BY_NAME                                       'bcdiv'
         85        SEND_VAR_EX                                              !1
         86        SEND_VAR_EX                                              !2
         87        DO_FCALL                                      0  $32     
         88        ADD                                              ~33     !3, $32
         89        SEND_VAL                                                 ~33
         90        DO_ICALL                                         $34     
         91        ECHO                                                     $34
         92      > JMP                                                      ->99
   44    93  E > > CATCH                                       last         'Error'
   45    94    >   ECHO                                                     'bcdiv%3A++++++++++'
         95        INIT_METHOD_CALL                                         !4, 'getMessage'
         96        DO_FCALL                                      0  $35     
         97        ECHO                                                     $35
         98        ECHO                                                     '%0A'
   48    99    >   ECHO                                                     '%0A'
        100        ECHO                                                     'And+the+results+with+an+int+cast+added+will+be%3A'
        101        ECHO                                                     '%0A'
   49   102        ECHO                                                     'ceil%3A+++++++++++'
        103        INIT_FCALL                                               'var_dump'
        104        INIT_FCALL                                               'ceil'
        105        DIV                                              ~36     !1, !2
        106        SEND_VAL                                                 ~36
        107        DO_ICALL                                         $37     
        108        CAST                                          4  ~38     $37
        109        SEND_VAL                                                 ~38
        110        DO_ICALL                                         $39     
        111        ECHO                                                     $39
   50   112        ECHO                                                     'round+%2B+ceil%3A+++'
        113        INIT_FCALL                                               'var_dump'
        114        INIT_FCALL                                               'round'
        115        INIT_FCALL                                               'ceil'
        116        DIV                                              ~40     !1, !2
        117        SEND_VAL                                                 ~40
        118        DO_ICALL                                         $41     
        119        SEND_VAR                                                 $41
        120        DO_ICALL                                         $42     
        121        CAST                                          4  ~43     $42
        122        SEND_VAL                                                 ~43
        123        DO_ICALL                                         $44     
        124        ECHO                                                     $44
   51   125        ECHO                                                     'wp_total_pages%3A+'
        126        INIT_FCALL                                               'var_dump'
        127        INIT_FCALL                                               'wp_total_pages'
        128        SEND_VAR                                                 !1
        129        SEND_VAR                                                 !2
        130        DO_FCALL                                      0  $45     
        131        CAST                                          4  ~46     $45
        132        SEND_VAL                                                 ~46
        133        DO_ICALL                                         $47     
        134        ECHO                                                     $47
   53   135        INIT_FCALL                                               'function_exists'
        136        SEND_VAL                                                 'intdiv'
        137        DO_ICALL                                         $48     
        138      > JMPZ                                                     $48, ->151
   54   139    >   ECHO                                                     'intdiv%3A+++++++++'
        140        INIT_FCALL                                               'var_dump'
        141        INIT_FCALL                                               'intdiv'
        142        SEND_VAR                                                 !1
        143        SEND_VAR                                                 !2
        144        DO_ICALL                                         $49     
        145        ADD                                              ~50     !3, $49
        146        CAST                                          4  ~51     ~50
        147        SEND_VAL                                                 ~51
        148        DO_ICALL                                         $52     
        149        ECHO                                                     $52
   53   150      > JMP                                                      ->153
   56   151    >   ECHO                                                     'intdiv+function+not+available'
        152        ECHO                                                     '%0A'
        153    > > JMP                                                      ->160
   58   154  E > > CATCH                                       last         'Error'
   59   155    >   ECHO                                                     'intdiv%3A+++++++++'
        156        INIT_METHOD_CALL                                         !4, 'getMessage'
        157        DO_FCALL                                      0  $53     
        158        ECHO                                                     $53
        159        ECHO                                                     '%0A'
   63   160    >   ECHO                                                     'bcdiv%3A++++++++++'
        161        INIT_FCALL                                               'var_dump'
        162        INIT_FCALL_BY_NAME                                       'bcdiv'
        163        SEND_VAR_EX                                              !1
        164        SEND_VAR_EX                                              !2
        165        DO_FCALL                                      0  $54     
        166        ADD                                              ~55     !3, $54
        167        CAST                                          4  ~56     ~55
        168        SEND_VAL                                                 ~56
        169        DO_ICALL                                         $57     
        170        ECHO                                                     $57
        171      > JMP                                                      ->178
   64   172  E > > CATCH                                       last         'Error'
   65   173    >   ECHO                                                     'bcdiv%3A++++++++++'
        174        INIT_METHOD_CALL                                         !4, 'getMessage'
        175        DO_FCALL                                      0  $58     
        176        ECHO                                                     $58
        177        ECHO                                                     '%0A'
   22   178    > > JMP                                                      ->2
        179    >   FE_FREE                                                  $6
   67   180      > RETURN                                                   1

Function wp_total_pages:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/V6jdD
function name:  wp_total_pages
number of ops:  10
compiled vars:  !0 = $total_items, !1 = $per_page, !2 = $remainder
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        MOD                                              ~3      !0, !1
          3        ASSIGN                                                   !2, ~3
    5     4      > JMPZ                                                     !2, ->7
    6     5    >   SUB                                              ~5      !1, !2
          6        ASSIGN_OP                                     1          !0, ~5
    8     7    >   DIV                                              ~7      !0, !1
          8      > RETURN                                                   ~7
    9     9*     > RETURN                                                   null

End of function wp_total_pages

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
189.65 ms | 1483 KiB | 20 Q