3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class HijriBirthday { public function convertSolarToLunar($year, $month, $date) { return HijriConverter::gregorianToHijri($year, $month, $date); } } class HijriConverter { public function intPart($float) { if ($float < -0.0000001) { return ceil($float - 0.0000001); } return floor($float + 0.0000001); } public function gregorianToHijri($y, $m, $d) { if ($y > 1700) { if (($y > 1582) || (($y == 1582) && ($m > 10)) || (($y == 1582) && ($m == 10) && ($d > 14))) { $jd = self::intPart( (1461 * ($y + 4800 + self::intPart(($m - 14) / 12))) / 4 ) + self::intPart( (367 * ($m - 2 - 12 * (self::intPart(($m - 14) / 12)))) / 12 ) - self::intPart((3 * ( self::intPart(($y + 4900 + self::intPart(($m - 14) / 12)) / 100) )) / 4) + $d - 32075; } else { $jd = 367 * $y - self::intPart( (7 * ($y + 5001 + self::intPart(($m - 9) / 7))) / 4 ) + self::intPart((275 * $m) / 9) + $d + 1729777; } $l = $jd - 1948440 + 10632; $n = self::intPart(($l - 1) / 10631); $l = $l - 10631 * $n + 354; $j = (self::intPart((10985 - $l) / 5316)) * (self::intPart(( 50 * $l) / 17719)) + (self::intPart($l / 5670)) * (self::intPart((43 * $l) / 15238)); $l = $l - (self::intPart((30 - $j) / 15)) * (self::intPart((17719 * $j) / 50)) - (self::intPart($j / 16)) * (self::intPart((15238 * $j) / 43)) + 29; $m = self::intPart((24 * $l) / 709); $d = $l - self::intPart((709 * $m) / 24); $y = 30 * $n + $j - 30; if ($d < 10) $d = "0".$d; if ($m < 10) $m = "0".$m; return array($y, $m, $d); } return array(); } } function main() { var_dump((new HijriBirthday)->convertSolarToLunar(1983, (double)31, 7)); var_dump((new HijriBirthday)->convertSolarToLunar(1983, (double)31, 7)); var_dump((new HijriBirthday)->convertSolarToLunar(1983, (double)31, 7)); } main(); echo "done\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ythek
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   66     0  E >   INIT_FCALL                                               'main'
          1        DO_FCALL                                      0          
   67     2        ECHO                                                     'done%0A'
          3      > RETURN                                                   1

Function main:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ythek
function name:  main
number of ops:  34
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   61     0  E >   INIT_FCALL                                               'var_dump'
          1        NEW                                              $0      'HijriBirthday'
          2        DO_FCALL                                      0          
          3        INIT_METHOD_CALL                                         $0, 'convertSolarToLunar'
          4        SEND_VAL_EX                                              1983
          5        CAST                                          5  ~2      31
          6        SEND_VAL_EX                                              ~2
          7        SEND_VAL_EX                                              7
          8        DO_FCALL                                      0  $3      
          9        SEND_VAR                                                 $3
         10        DO_ICALL                                                 
   62    11        INIT_FCALL                                               'var_dump'
         12        NEW                                              $5      'HijriBirthday'
         13        DO_FCALL                                      0          
         14        INIT_METHOD_CALL                                         $5, 'convertSolarToLunar'
         15        SEND_VAL_EX                                              1983
         16        CAST                                          5  ~7      31
         17        SEND_VAL_EX                                              ~7
         18        SEND_VAL_EX                                              7
         19        DO_FCALL                                      0  $8      
         20        SEND_VAR                                                 $8
         21        DO_ICALL                                                 
   63    22        INIT_FCALL                                               'var_dump'
         23        NEW                                              $10     'HijriBirthday'
         24        DO_FCALL                                      0          
         25        INIT_METHOD_CALL                                         $10, 'convertSolarToLunar'
         26        SEND_VAL_EX                                              1983
         27        CAST                                          5  ~12     31
         28        SEND_VAL_EX                                              ~12
         29        SEND_VAL_EX                                              7
         30        DO_FCALL                                      0  $13     
         31        SEND_VAR                                                 $13
         32        DO_ICALL                                                 
   64    33      > RETURN                                                   null

End of function main

Class HijriBirthday:
Function convertsolartolunar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ythek
function name:  convertSolarToLunar
number of ops:  10
compiled vars:  !0 = $year, !1 = $month, !2 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    5     3        INIT_STATIC_METHOD_CALL                                  'HijriConverter', 'gregorianToHijri'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0  $3      
          8      > RETURN                                                   $3
    6     9*     > RETURN                                                   null

End of function convertsolartolunar

End of class HijriBirthday.

Class HijriConverter:
Function intpart:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ythek
function name:  intPart
number of ops:  14
compiled vars:  !0 = $float
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        IS_SMALLER                                               !0, -1.0e-7
          2      > JMPZ                                                     ~1, ->8
   13     3    >   INIT_FCALL                                               'ceil'
          4        SUB                                              ~2      !0, 1.0e-7
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7      > RETURN                                                   $3
   15     8    >   INIT_FCALL                                               'floor'
          9        ADD                                              ~4      !0, 1.0e-7
         10        SEND_VAL                                                 ~4
         11        DO_ICALL                                         $5      
         12      > RETURN                                                   $5
   16    13*     > RETURN                                                   null

End of function intpart

Function gregoriantohijri:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 182
Branch analysis from position: 5
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 47) Position 1 = 13, Position 2 = 21
Branch analysis from position: 13
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 69
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 92
Branch analysis from position: 92
2 jumps found. (Code = 43) Position 1 = 172, Position 2 = 174
Branch analysis from position: 172
2 jumps found. (Code = 43) Position 1 = 176, Position 2 = 178
Branch analysis from position: 176
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 178
Branch analysis from position: 174
Branch analysis from position: 69
2 jumps found. (Code = 43) Position 1 = 172, Position 2 = 174
Branch analysis from position: 172
Branch analysis from position: 174
Branch analysis from position: 20
Branch analysis from position: 17
Branch analysis from position: 21
Branch analysis from position: 11
Branch analysis from position: 12
Branch analysis from position: 182
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ythek
function name:  gregorianToHijri
number of ops:  184
compiled vars:  !0 = $y, !1 = $m, !2 = $d, !3 = $jd, !4 = $l, !5 = $n, !6 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   19     3        IS_SMALLER                                               1700, !0
          4      > JMPZ                                                     ~7, ->182
   20     5    >   IS_SMALLER                                       ~8      1582, !0
          6      > JMPNZ_EX                                         ~8      ~8, ->12
          7    >   IS_EQUAL                                         ~9      !0, 1582
          8      > JMPZ_EX                                          ~9      ~9, ->11
          9    >   IS_SMALLER                                       ~10     10, !1
         10        BOOL                                             ~9      ~10
         11    >   BOOL                                             ~8      ~9
         12    > > JMPNZ_EX                                         ~8      ~8, ->21
   21    13    >   IS_EQUAL                                         ~11     !0, 1582
         14      > JMPZ_EX                                          ~11     ~11, ->17
         15    >   IS_EQUAL                                         ~12     !1, 10
         16        BOOL                                             ~11     ~12
         17    > > JMPZ_EX                                          ~11     ~11, ->20
         18    >   IS_SMALLER                                       ~13     14, !2
         19        BOOL                                             ~11     ~13
         20    >   BOOL                                             ~8      ~11
         21    > > JMPZ                                                     ~8, ->69
   22    22    >   INIT_STATIC_METHOD_CALL                                  'intPart'
   23    23        ADD                                              ~14     !0, 4800
         24        INIT_STATIC_METHOD_CALL                                  'intPart'
         25        SUB                                              ~15     !1, 14
         26        DIV                                              ~16     ~15, 12
         27        SEND_VAL                                                 ~16
         28        DO_FCALL                                      0  $17     
         29        ADD                                              ~18     ~14, $17
         30        MUL                                              ~19     ~18, 1461
         31        DIV                                              ~20     ~19, 4
         32        SEND_VAL                                                 ~20
         33        DO_FCALL                                      0  $21     
   24    34        INIT_STATIC_METHOD_CALL                                  'intPart'
   25    35        SUB                                              ~22     !1, 2
         36        INIT_STATIC_METHOD_CALL                                  'intPart'
         37        SUB                                              ~23     !1, 14
         38        DIV                                              ~24     ~23, 12
         39        SEND_VAL                                                 ~24
         40        DO_FCALL                                      0  $25     
         41        MUL                                              ~26     $25, 12
         42        SUB                                              ~27     ~22, ~26
         43        MUL                                              ~28     ~27, 367
         44        DIV                                              ~29     ~28, 12
         45        SEND_VAL                                                 ~29
         46        DO_FCALL                                      0  $30     
         47        ADD                                              ~31     $21, $30
   26    48        INIT_STATIC_METHOD_CALL                                  'intPart'
   27    49        INIT_STATIC_METHOD_CALL                                  'intPart'
         50        ADD                                              ~32     !0, 4900
         51        INIT_STATIC_METHOD_CALL                                  'intPart'
         52        SUB                                              ~33     !1, 14
         53        DIV                                              ~34     ~33, 12
         54        SEND_VAL                                                 ~34
         55        DO_FCALL                                      0  $35     
         56        ADD                                              ~36     ~32, $35
         57        DIV                                              ~37     ~36, 100
         58        SEND_VAL                                                 ~37
         59        DO_FCALL                                      0  $38     
         60        MUL                                              ~39     $38, 3
   28    61        DIV                                              ~40     ~39, 4
         62        SEND_VAL                                                 ~40
         63        DO_FCALL                                      0  $41     
         64        SUB                                              ~42     ~31, $41
         65        ADD                                              ~43     ~42, !2
         66        SUB                                              ~44     ~43, 32075
   22    67        ASSIGN                                                   !3, ~44
         68      > JMP                                                      ->92
   30    69    >   MUL                                              ~46     !0, 367
         70        INIT_STATIC_METHOD_CALL                                  'intPart'
   31    71        ADD                                              ~47     !0, 5001
         72        INIT_STATIC_METHOD_CALL                                  'intPart'
         73        SUB                                              ~48     !1, 9
         74        DIV                                              ~49     ~48, 7
         75        SEND_VAL                                                 ~49
         76        DO_FCALL                                      0  $50     
         77        ADD                                              ~51     ~47, $50
         78        MUL                                              ~52     ~51, 7
         79        DIV                                              ~53     ~52, 4
         80        SEND_VAL                                                 ~53
         81        DO_FCALL                                      0  $54     
         82        SUB                                              ~55     ~46, $54
   32    83        INIT_STATIC_METHOD_CALL                                  'intPart'
         84        MUL                                              ~56     !1, 275
         85        DIV                                              ~57     ~56, 9
         86        SEND_VAL                                                 ~57
         87        DO_FCALL                                      0  $58     
         88        ADD                                              ~59     ~55, $58
         89        ADD                                              ~60     ~59, !2
         90        ADD                                              ~61     ~60, 1729777
   30    91        ASSIGN                                                   !3, ~61
   35    92    >   SUB                                              ~63     !3, 1948440
         93        ADD                                              ~64     ~63, 10632
         94        ASSIGN                                                   !4, ~64
   36    95        INIT_STATIC_METHOD_CALL                                  'intPart'
         96        SUB                                              ~66     !4, 1
         97        DIV                                              ~67     ~66, 10631
         98        SEND_VAL                                                 ~67
         99        DO_FCALL                                      0  $68     
        100        ASSIGN                                                   !5, $68
   37   101        MUL                                              ~70     !5, 10631
        102        SUB                                              ~71     !4, ~70
        103        ADD                                              ~72     ~71, 354
        104        ASSIGN                                                   !4, ~72
   38   105        INIT_STATIC_METHOD_CALL                                  'intPart'
        106        SUB                                              ~74     10985, !4
        107        DIV                                              ~75     ~74, 5316
        108        SEND_VAL                                                 ~75
        109        DO_FCALL                                      0  $76     
   39   110        INIT_STATIC_METHOD_CALL                                  'intPart'
        111        MUL                                              ~77     !4, 50
        112        DIV                                              ~78     ~77, 17719
        113        SEND_VAL                                                 ~78
        114        DO_FCALL                                      0  $79     
        115        MUL                                              ~80     $76, $79
   40   116        INIT_STATIC_METHOD_CALL                                  'intPart'
        117        DIV                                              ~81     !4, 5670
        118        SEND_VAL                                                 ~81
        119        DO_FCALL                                      0  $82     
        120        INIT_STATIC_METHOD_CALL                                  'intPart'
        121        MUL                                              ~83     !4, 43
        122        DIV                                              ~84     ~83, 15238
        123        SEND_VAL                                                 ~84
        124        DO_FCALL                                      0  $85     
        125        MUL                                              ~86     $82, $85
        126        ADD                                              ~87     ~80, ~86
   38   127        ASSIGN                                                   !6, ~87
   41   128        INIT_STATIC_METHOD_CALL                                  'intPart'
        129        SUB                                              ~89     30, !6
        130        DIV                                              ~90     ~89, 15
        131        SEND_VAL                                                 ~90
        132        DO_FCALL                                      0  $91     
   42   133        INIT_STATIC_METHOD_CALL                                  'intPart'
        134        MUL                                              ~92     !6, 17719
        135        DIV                                              ~93     ~92, 50
        136        SEND_VAL                                                 ~93
        137        DO_FCALL                                      0  $94     
        138        MUL                                              ~95     $91, $94
        139        SUB                                              ~96     !4, ~95
   43   140        INIT_STATIC_METHOD_CALL                                  'intPart'
        141        DIV                                              ~97     !6, 16
        142        SEND_VAL                                                 ~97
        143        DO_FCALL                                      0  $98     
        144        INIT_STATIC_METHOD_CALL                                  'intPart'
        145        MUL                                              ~99     !6, 15238
        146        DIV                                              ~100    ~99, 43
        147        SEND_VAL                                                 ~100
        148        DO_FCALL                                      0  $101    
        149        MUL                                              ~102    $98, $101
        150        SUB                                              ~103    ~96, ~102
        151        ADD                                              ~104    ~103, 29
   41   152        ASSIGN                                                   !4, ~104
   44   153        INIT_STATIC_METHOD_CALL                                  'intPart'
        154        MUL                                              ~106    !4, 24
        155        DIV                                              ~107    ~106, 709
        156        SEND_VAL                                                 ~107
        157        DO_FCALL                                      0  $108    
        158        ASSIGN                                                   !1, $108
   45   159        INIT_STATIC_METHOD_CALL                                  'intPart'
        160        MUL                                              ~110    !1, 709
        161        DIV                                              ~111    ~110, 24
        162        SEND_VAL                                                 ~111
        163        DO_FCALL                                      0  $112    
        164        SUB                                              ~113    !4, $112
        165        ASSIGN                                                   !2, ~113
   46   166        MUL                                              ~115    !5, 30
        167        ADD                                              ~116    ~115, !6
        168        SUB                                              ~117    ~116, 30
        169        ASSIGN                                                   !0, ~117
   48   170        IS_SMALLER                                               !2, 10
        171      > JMPZ                                                     ~119, ->174
   49   172    >   CONCAT                                           ~120    '0', !2
        173        ASSIGN                                                   !2, ~120
   51   174    >   IS_SMALLER                                               !1, 10
        175      > JMPZ                                                     ~122, ->178
   52   176    >   CONCAT                                           ~123    '0', !1
        177        ASSIGN                                                   !1, ~123
   54   178    >   INIT_ARRAY                                       ~125    !0
        179        ADD_ARRAY_ELEMENT                                ~125    !1
        180        ADD_ARRAY_ELEMENT                                ~125    !2
        181      > RETURN                                                   ~125
   56   182    > > RETURN                                                   <array>
   57   183*     > RETURN                                                   null

End of function gregoriantohijri

End of class HijriConverter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.09 ms | 1419 KiB | 20 Q