{"id":275,"date":"2024-06-07T15:04:23","date_gmt":"2024-06-07T07:04:23","guid":{"rendered":"https:\/\/www.nickyoo7.com\/?p=275"},"modified":"2024-06-07T15:04:23","modified_gmt":"2024-06-07T07:04:23","slug":"php-%e8%be%b2%e6%9b%86%e6%8f%9b%e7%ae%97","status":"publish","type":"post","link":"https:\/\/www.nickyoo7.com\/?p=275","title":{"rendered":"PHP \u8fb2\u66c6\u63db\u7b97"},"content":{"rendered":"<p>\u53c3\u8003\u8cc7\u6599 : https:\/\/gist.github.com\/jfcherng\/4eb9c81c95b42a1b9f188a7f70f4e420<\/p>\n<p><!--more--><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">&lt;?php\r\n\r\nclass Lunar\r\n{\r\n    const MIN_YEAR = 1891;\r\n    const MAX_YEAR = 2100;\r\n\r\n    const LUNAR_INFO = [\r\n        [0, 2, 9, 21936], [6, 1, 30, 9656], [0, 2, 17, 9584], [0, 2, 6, 21168], [5, 1, 26, 43344], [0, 2, 13, 59728],\r\n        [0, 2, 2, 27296], [3, 1, 22, 44368], [0, 2, 10, 43856], [8, 1, 30, 19304], [0, 2, 19, 19168], [0, 2, 8, 42352],\r\n        [5, 1, 29, 21096], [0, 2, 16, 53856], [0, 2, 4, 55632], [4, 1, 25, 27304], [0, 2, 13, 22176], [0, 2, 2, 39632],\r\n        [2, 1, 22, 19176], [0, 2, 10, 19168], [6, 1, 30, 42200], [0, 2, 18, 42192], [0, 2, 6, 53840], [5, 1, 26, 54568],\r\n        [0, 2, 14, 46400], [0, 2, 3, 54944], [2, 1, 23, 38608], [0, 2, 11, 38320], [7, 2, 1, 18872], [0, 2, 20, 18800],\r\n        [0, 2, 8, 42160], [5, 1, 28, 45656], [0, 2, 16, 27216], [0, 2, 5, 27968], [4, 1, 24, 44456], [0, 2, 13, 11104],\r\n        [0, 2, 2, 38256], [2, 1, 23, 18808], [0, 2, 10, 18800], [6, 1, 30, 25776], [0, 2, 17, 54432], [0, 2, 6, 59984],\r\n        [5, 1, 26, 27976], [0, 2, 14, 23248], [0, 2, 4, 11104], [3, 1, 24, 37744], [0, 2, 11, 37600], [7, 1, 31, 51560],\r\n        [0, 2, 19, 51536], [0, 2, 8, 54432], [6, 1, 27, 55888], [0, 2, 15, 46416], [0, 2, 5, 22176], [4, 1, 25, 43736],\r\n        [0, 2, 13, 9680], [0, 2, 2, 37584], [2, 1, 22, 51544], [0, 2, 10, 43344], [7, 1, 29, 46248], [0, 2, 17, 27808],\r\n        [0, 2, 6, 46416], [5, 1, 27, 21928], [0, 2, 14, 19872], [0, 2, 3, 42416], [3, 1, 24, 21176], [0, 2, 12, 21168],\r\n        [8, 1, 31, 43344], [0, 2, 18, 59728], [0, 2, 8, 27296], [6, 1, 28, 44368], [0, 2, 15, 43856], [0, 2, 5, 19296],\r\n        [4, 1, 25, 42352], [0, 2, 13, 42352], [0, 2, 2, 21088], [3, 1, 21, 59696], [0, 2, 9, 55632], [7, 1, 30, 23208],\r\n        [0, 2, 17, 22176], [0, 2, 6, 38608], [5, 1, 27, 19176], [0, 2, 15, 19152], [0, 2, 3, 42192], [4, 1, 23, 53864],\r\n        [0, 2, 11, 53840], [8, 1, 31, 54568], [0, 2, 18, 46400], [0, 2, 7, 46752], [6, 1, 28, 38608], [0, 2, 16, 38320],\r\n        [0, 2, 5, 18864], [4, 1, 25, 42168], [0, 2, 13, 42160], [10, 2, 2, 45656], [0, 2, 20, 27216], [0, 2, 9, 27968],\r\n        [6, 1, 29, 44448], [0, 2, 17, 43872], [0, 2, 6, 38256], [5, 1, 27, 18808], [0, 2, 15, 18800], [0, 2, 4, 25776],\r\n        [3, 1, 23, 27216], [0, 2, 10, 59984], [8, 1, 31, 27432], [0, 2, 19, 23232], [0, 2, 7, 43872], [5, 1, 28, 37736],\r\n        [0, 2, 16, 37600], [0, 2, 5, 51552], [4, 1, 24, 54440], [0, 2, 12, 54432], [0, 2, 1, 55888], [2, 1, 22, 23208],\r\n        [0, 2, 9, 22176], [7, 1, 29, 43736], [0, 2, 18, 9680], [0, 2, 7, 37584], [5, 1, 26, 51544], [0, 2, 14, 43344],\r\n        [0, 2, 3, 46240], [4, 1, 23, 46416], [0, 2, 10, 44368], [9, 1, 31, 21928], [0, 2, 19, 19360], [0, 2, 8, 42416],\r\n        [6, 1, 28, 21176], [0, 2, 16, 21168], [0, 2, 5, 43312], [4, 1, 25, 29864], [0, 2, 12, 27296], [0, 2, 1, 44368],\r\n        [2, 1, 22, 19880], [0, 2, 10, 19296], [6, 1, 29, 42352], [0, 2, 17, 42208], [0, 2, 6, 53856], [5, 1, 26, 59696],\r\n        [0, 2, 13, 54576], [0, 2, 3, 23200], [3, 1, 23, 27472], [0, 2, 11, 38608], [11, 1, 31, 19176], [0, 2, 19, 19152],\r\n        [0, 2, 8, 42192], [6, 1, 28, 53848], [0, 2, 15, 53840], [0, 2, 4, 54560], [5, 1, 24, 55968], [0, 2, 12, 46496],\r\n        [0, 2, 1, 22224], [2, 1, 22, 19160], [0, 2, 10, 18864], [7, 1, 30, 42168], [0, 2, 17, 42160], [0, 2, 6, 43600],\r\n        [5, 1, 26, 46376], [0, 2, 14, 27936], [0, 2, 2, 44448], [3, 1, 23, 21936], [0, 2, 11, 37744], [8, 2, 1, 18808],\r\n        [0, 2, 19, 18800], [0, 2, 8, 25776], [6, 1, 28, 27216], [0, 2, 15, 59984], [0, 2, 4, 27424], [4, 1, 24, 43872],\r\n        [0, 2, 12, 43744], [0, 2, 2, 37600], [3, 1, 21, 51568], [0, 2, 9, 51552], [7, 1, 29, 54440], [0, 2, 17, 54432],\r\n        [0, 2, 5, 55888], [5, 1, 26, 23208], [0, 2, 14, 22176], [0, 2, 3, 42704], [4, 1, 23, 21224], [0, 2, 11, 21200],\r\n        [8, 1, 31, 43352], [0, 2, 19, 43344], [0, 2, 7, 46240], [6, 1, 27, 46416], [0, 2, 15, 44368], [0, 2, 5, 21920],\r\n        [4, 1, 24, 42448], [0, 2, 12, 42416], [0, 2, 2, 21168], [3, 1, 22, 43320], [0, 2, 9, 26928], [7, 1, 29, 29336],\r\n        [0, 2, 17, 27296], [0, 2, 6, 44368], [5, 1, 26, 19880], [0, 2, 14, 19296], [0, 2, 3, 42352], [4, 1, 24, 21104],\r\n        [0, 2, 10, 53856], [8, 1, 30, 59696], [0, 2, 18, 54560], [0, 2, 7, 55968], [6, 1, 27, 27472], [0, 2, 15, 22224],\r\n        [0, 2, 5, 19168], [4, 1, 25, 42216], [0, 2, 12, 42192], [0, 2, 1, 53584], [2, 1, 21, 55592], [0, 2, 9, 54560],\r\n    ];\r\n\r\n    const SKY = [\r\n        '\u5e9a', '\u8f9b', '\u58ec', '\u7678',\r\n        '\u7532', '\u4e59', '\u4e19', '\u4e01',\r\n        '\u620a', '\u5df1',\r\n    ];\r\n\r\n    const EARTH = [\r\n        '\u7533', '\u9149', '\u620c', '\u4ea5',\r\n        '\u5b50', '\u4e11', '\u5bc5', '\u536f',\r\n        '\u8fb0', '\u5df3', '\u5348', '\u672a',\r\n    ];\r\n\r\n    const ZODIAC = [\r\n        '\u7334', '\u96de', '\u72d7', '\u8c6c', '\u9f20', '\u725b',\r\n        '\u864e', '\u5154', '\u9f8d', '\u86c7', '\u99ac', '\u7f8a',\r\n    ];\r\n\r\n    const DATE_HASH = [\r\n        '',\r\n        '\u4e00', '\u4e8c', '\u4e09', '\u56db', '\u4e94',\r\n        '\u516d', '\u4e03', '\u516b', '\u4e5d', '\u5341',\r\n    ];\r\n\r\n    const MONTH_HASH = [\r\n        '',\r\n        '\u6b63\u6708', '\u4e8c\u6708', '\u4e09\u6708', '\u56db\u6708', '\u4e94\u6708', '\u516d\u6708',\r\n        '\u4e03\u6708', '\u516b\u6708', '\u4e5d\u6708', '\u5341\u6708', '\u51ac\u6708', '\u81d8\u6708',\r\n    ];\r\n\r\n    const MONTH_DAYS = [\r\n        31, -1, 31, 30, 31, 30,\r\n        31, 31, 30, 31, 30, 31,\r\n    ];\r\n\r\n    \/**\r\n     * \u5c07\u967d\u66c6\u8f49\u63db\u70ba\u9670\u66c6.\r\n     *\r\n     * @param int $year  \u516c\u66c6-\u5e74\r\n     * @param int $month \u516c\u66c6-\u6708\r\n     * @param int $date  \u516c\u66c6-\u65e5\r\n     *\r\n     * @return array\r\n     *\/\r\n    public function convertSolarToLunar(int $year, int $month, int $date): array\r\n    {\r\n        \/\/debugger;\r\n        $yearData = static::LUNAR_INFO[$year - static::MIN_YEAR];\r\n        if ($year === static::MIN_YEAR &amp;&amp; $month &lt;= 2 &amp;&amp; $date &lt;= 9) {\r\n            return [1891, '\u6b63\u6708', '\u521d\u4e00', '\u8f9b\u536f', 1, 1, '\u5154'];\r\n        }\r\n\r\n        return $this-&gt;getLunarByBetween(\r\n            $year,\r\n            $this-&gt;getDaysBetweenSolar($year, $month, $date, $yearData[1], $yearData[2])\r\n        );\r\n    }\r\n\r\n    public function convertSolarMonthToLunar(int $year, int $month): array\r\n    {\r\n        $yearData = static::LUNAR_INFO[$year - static::MIN_YEAR];\r\n\r\n        $dd = $this-&gt;getSolarMonthDays($year, $month);\r\n        if ($this-&gt;isLeapYear($year) &amp;&amp; $month === 2) {\r\n            ++$dd;\r\n        }\r\n\r\n        $lunar_ary = [];\r\n        for ($i = 1; $i &lt; $dd; ++$i) {\r\n            $array = $this-&gt;getLunarByBetween(\r\n                $year,\r\n                $this-&gt;getDaysBetweenSolar($year, $month, $i, $yearData[1], $yearData[2])\r\n            );\r\n            $array[] = $year . '-' . $month . '-' . $i;\r\n            $lunar_ary[$i] = $array;\r\n        }\r\n\r\n        return $lunar_ary;\r\n    }\r\n\r\n    \/**\r\n     * \u5c07\u9670\u66c6\u8f49\u63db\u70ba\u967d\u66c6.\r\n     *\r\n     * @param int $year  \u9670\u66c6-\u5e74\r\n     * @param int $month \u9670\u66c6-\u6708\uff0c\u958f\u6708\u8655\u7406\uff1a\u4f8b\u5982\u5982\u679c\u7576\u5e74\u958f\u4e94\u6708\uff0c\u90a3\u9ebc\u7b2c\u4e8c\u500b\u4e94\u6708\u5c31\u50b3\u516d\u6708\uff0c\u76f8\u7576\u65bc\u9670\u66c6\u670913\u500b\u6708\uff0c\u53ea\u662f\u6709\u7684\u6642\u5019\u7b2c13\u500b\u6708\u7684\u5929\u6578\u70ba0\r\n     * @param int $date  \u9670\u66c6-\u65e5\r\n     *\r\n     * @return array\r\n     *\/\r\n    public function convertLunarToSolar(int $year, int $month, int $date): array\r\n    {\r\n        $yearData = static::LUNAR_INFO[$year - static::MIN_YEAR];\r\n        $between = $this-&gt;getDaysBetweenLunar($year, $month, $date);\r\n\r\n        $res = mktime(0, 0, 0, $yearData[1], $yearData[2], $year);\r\n        $res = date('Y-m-d', $res + $between * 24 * 60 * 60);\r\n\r\n        return explode('-', $res);\r\n    }\r\n\r\n    \/**\r\n     * \u5224\u65b7\u662f\u5426\u662f\u958f\u5e74.\r\n     *\r\n     * @param int $year The year\r\n     *\r\n     * @return bool true if leap year, False otherwise\r\n     *\/\r\n    public function isLeapYear(int $year): bool\r\n    {\r\n        return ($year &amp; 3 === 0 &amp;&amp; $year % 100 !== 0) || ($year % 400 === 0);\r\n    }\r\n\r\n    \/**\r\n     * \u7372\u53d6\u5e72\u652f\u7d00\u5e74.\r\n     *\r\n     * @param int $year The year\r\n     *\r\n     * @return string the lunar year name\r\n     *\/\r\n    public function getLunarYearName(int $year): string\r\n    {\r\n        return static::SKY[$year % 10] . static::EARTH[$year % 12];\r\n    }\r\n\r\n    \/**\r\n     * \u6839\u64da\u9670\u66c6\u5e74\u7372\u53d6\u751f\u8096.\r\n     *\r\n     * @param int $year \u9670\u66c6\u5e74\r\n     *\r\n     * @return array the year zodiac\r\n     *\/\r\n    public function getYearZodiac(int $year): string\r\n    {\r\n        return static::ZODIAC[$year % 12];\r\n    }\r\n\r\n    \/**\r\n     * \u7372\u53d6\u967d\u66c6\u6708\u4efd\u7684\u5929\u6578.\r\n     *\r\n     * @param int $year  \u967d\u66c6-\u5e74\r\n     * @param int $month \u967d\u66c6-\u6708\r\n     *\r\n     * @return int the solar month days\r\n     *\/\r\n    public function getSolarMonthDays(int $year, int $month): int\r\n    {\r\n        return $month === 2\r\n            ? ($this-&gt;isLeapYear($year) ? 29 : 28)\r\n            : static::MONTH_DAYS[$month];\r\n    }\r\n\r\n    \/**\r\n     * \u7372\u53d6\u9670\u66c6\u6708\u4efd\u7684\u5929\u6578.\r\n     *\r\n     * @param int $year  \u9670\u66c6-\u5e74\r\n     * @param int $month \u9670\u66c6-\u6708\uff0c\u5f9e\u4e00\u6708\u958b\u59cb\r\n     *\r\n     * @return int the lunar month days\r\n     *\/\r\n    public function getLunarMonthDays(int $year, int $month): int\r\n    {\r\n        return $this-&gt;getLunarMonths($year)[$month - 1];\r\n    }\r\n\r\n    \/**\r\n     * \u7372\u53d6\u9670\u66c6\u6bcf\u6708\u7684\u5929\u6578\u7684\u6578\u7d44.\r\n     *\r\n     * @param int $year The year\r\n     *\r\n     * @return array the lunar months\r\n     *\/\r\n    public function getLunarMonths(int $year): array\r\n    {\r\n        $yearData = static::LUNAR_INFO[$year - static::MIN_YEAR];\r\n        $leapMonth = $yearData[0];\r\n        $bit = decbin($yearData[3]);\r\n\r\n        for ($i = 0; $i &lt; strlen($bit); ++$i) {\r\n            $bitArray[$i] = substr($bit, $i, 1);\r\n        }\r\n\r\n        for ($k = 0,$klen = 16 - count($bitArray); $k &lt; $klen; ++$k) {\r\n            array_unshift($bitArray, '0');\r\n        }\r\n\r\n        $bitArray = array_slice($bitArray, 0, ($leapMonth === 0 ? 12 : 13));\r\n        for ($i = 0; $i &lt; count($bitArray); ++$i) {\r\n            $bitArray[$i] = $bitArray[$i] + 29;\r\n        }\r\n\r\n        return $bitArray;\r\n    }\r\n\r\n    \/**\r\n     * \u7372\u53d6\u8fb2\u66c6\u6bcf\u5e74\u7684\u5929\u6578.\r\n     *\r\n     * @param int $year \u8fb2\u66c6\u5e74\u4efd\r\n     *\r\n     * @return int the lunar year days\r\n     *\/\r\n    public function getLunarYearDays(int $year): int\r\n    {\r\n        $monthArray = $this-&gt;getLunarYearMonths($year);\r\n        $len = count($monthArray);\r\n\r\n        return $monthArray[$len - 1] === 0 ? $monthArray[$len - 2] : $monthArray[$len - 1];\r\n    }\r\n\r\n    \/**\r\n     * \u7372\u53d6\u8fb2\u66c6\u6bcf\u5e74\u7684\u6708\u6578.\r\n     *\r\n     * @param int $year The year\r\n     *\r\n     * @return array the lunar year months\r\n     *\/\r\n    public function getLunarYearMonths(int $year): array\r\n    {\r\n        \/\/debugger\r\n        $monthData = $this-&gt;getLunarMonths($year);\r\n        $res = [];\r\n        $temp = 0;\r\n        $yearData = static::LUNAR_INFO[$year - static::MIN_YEAR];\r\n        $len = ($yearData[0] === 0 ? 12 : 13);\r\n\r\n        for ($i = 0; $i &lt; $len; ++$i) {\r\n            $temp = 0;\r\n            for ($j = 0; $j &lt;= $i; ++$j) {\r\n                $temp += $monthData[$j];\r\n            }\r\n            $res[] = $temp;\r\n        }\r\n\r\n        return $res;\r\n    }\r\n\r\n    \/**\r\n     * \u7372\u53d6\u958f\u6708.\r\n     *\r\n     * @param int $year \u9670\u66c6\u5e74\u4efd\r\n     *\r\n     * @return int the leap month\r\n     *\/\r\n    public function getLeapMonth(int $year): int\r\n    {\r\n        return static::LUNAR_INFO[$year - static::MIN_YEAR][0];\r\n    }\r\n\r\n    \/**\r\n     * \u8a08\u7b97\u9670\u66c6\u65e5\u671f\u8207\u6b63\u6708\u521d\u4e00\u76f8\u9694\u7684\u5929\u6578.\r\n     *\r\n     * @param int $year  The year\r\n     * @param int $month The month\r\n     * @param int $date  The date\r\n     *\r\n     * @return int the days between lunar\r\n     *\/\r\n    public function getDaysBetweenLunar(int $year, int $month, int $date): int\r\n    {\r\n        $yearMonth = $this-&gt;getLunarMonths($year);\r\n\r\n        $res = 0;\r\n        for ($i = 1; $i &lt; $month; ++$i) {\r\n            $res += $yearMonth[$i - 1];\r\n        }\r\n        $res += $date - 1;\r\n\r\n        return $res;\r\n    }\r\n\r\n    \/**\r\n     * \u8a08\u7b972\u500b\u967d\u66c6\u65e5\u671f\u4e4b\u9593\u7684\u5929\u6578.\r\n     *\r\n     * @param int $year   \u967d\u66c6\u5e74\r\n     * @param int $cmonth The cmonth\r\n     * @param int $cdate  The cdate\r\n     * @param int $dmonth \u9670\u66c6\u6b63\u6708\u5c0d\u61c9\u7684\u967d\u66c6\u6708\u4efd\r\n     * @param int $ddate  \u9670\u66c6\u521d\u4e00\u5c0d\u61c9\u7684\u967d\u66c6\u5929\u6578\r\n     *\r\n     * @return int the days between solar\r\n     *\/\r\n    public function getDaysBetweenSolar(int $year, int $cmonth, int $cdate, int $dmonth, int $ddate): int\r\n    {\r\n        $a = mktime(0, 0, 0, $cmonth, $cdate, $year);\r\n        $b = mktime(0, 0, 0, $dmonth, $ddate, $year);\r\n\r\n        return ceil(($a - $b) \/ 24 \/ 3600);\r\n    }\r\n\r\n    \/**\r\n     * \u6839\u64da\u8ddd\u96e2\u6b63\u6708\u521d\u4e00\u7684\u5929\u6578\u8a08\u7b97\u9670\u66c6\u65e5\u671f\r\n     *\r\n     * @param int $year    \u967d\u66c6\u5e74\r\n     * @param int $between \u5929\u6578\r\n     *\r\n     * @return array the lunar by between\r\n     *\/\r\n    public function getLunarByBetween(int $year, int $between): array\r\n    {\r\n        \/\/ debugger\r\n        $lunarArray = [];\r\n        $yearMonth = [];\r\n        $t = 0;\r\n        $e = 0;\r\n        $leapMonth = 0;\r\n        $m = '';\r\n\r\n        if ($between === 0) {\r\n            array_push($lunarArray, $year, '\u6b63\u6708', '\u521d\u4e00');\r\n            $t = 1;\r\n            $e = 1;\r\n        } else {\r\n            $year = $between &gt; 0 ? $year : ($year - 1);\r\n            $yearMonth = $this-&gt;getLunarYearMonths($year);\r\n            $leapMonth = $this-&gt;getLeapMonth($year);\r\n            $between = $between &gt; 0 ? $between : ($this-&gt;getLunarYearDays($year) + $between);\r\n\r\n            for ($i = 0; $i &lt; 13; ++$i) {\r\n                if ($between === $yearMonth[$i]) {\r\n                    $t = $i + 2;\r\n                    $e = 1;\r\n                    break;\r\n                }\r\n                if ($between &lt; $yearMonth[$i]) {\r\n                    $t = $i + 1;\r\n                    $e = $between - (empty($yearMonth[$i - 1]) ? 0 : $yearMonth[$i - 1]) + 1;\r\n                    break;\r\n                }\r\n            }\r\n\r\n            $m = ($leapMonth !== 0 &amp;&amp; $t === $leapMonth + 1)\r\n                ? ('\u958f' . $this-&gt;getCapitalNum($t - 1, true))\r\n                : $this-&gt;getCapitalNum(($leapMonth !== 0 &amp;&amp; $leapMonth + 1 &lt; $t ? ($t - 1) : $t), true);\r\n\r\n            array_push($lunarArray, $year, $m, $this-&gt;getCapitalNum($e, false));\r\n        }\r\n\r\n        array_push(\r\n            $lunarArray,\r\n            $this-&gt;getLunarYearName($year), \/\/ \u5929\u5e72\u5730\u652f\r\n            $t,\r\n            $e,\r\n            $this-&gt;getYearZodiac($year), \/\/ \u751f\u8096\r\n            $leapMonth \/\/ \u958f\u5e7e\u6708\r\n        );\r\n\r\n        return $lunarArray;\r\n    }\r\n\r\n    \/**\r\n     * \u7372\u53d6\u6578\u5b57\u7684\u9670\u66c6\u53eb\u6cd5.\r\n     *\r\n     * @param int  $num     \u6578\u5b57\r\n     * @param bool $isMonth \u662f\u5426\u662f\u6708\u4efd\u7684\u6578\u5b57\r\n     *\r\n     * @return string the capital number\r\n     *\/\r\n    public function getCapitalNum(int $num, bool $isMonth = false): string\r\n    {\r\n        if ($isMonth) {\r\n            return static::MONTH_HASH[$num];\r\n        }\r\n\r\n        if ($num &lt;= 10) {\r\n            $res = '\u521d' . static::DATE_HASH[$num];\r\n        } elseif ($num &lt; 20) {\r\n            $res = '\u5341' . static::DATE_HASH[$num - 10];\r\n        } elseif ($num === 20) {\r\n            $res = '\u4e8c\u5341';\r\n        } elseif ($num &lt; 30) {\r\n            $res = '\u5eff' . static::DATE_HASH[$num - 20];\r\n        } elseif ($num === 30) {\r\n            $res = '\u4e09\u5341';\r\n        } else {\r\n            $res = '';\r\n        }\r\n\r\n        return $res;\r\n    }\r\n}\r\n\r\nfunction demo() {\r\n    $lunar = new Lunar();\r\n    $month = $lunar-&gt;convertSolarToLunar(2018, 1, 2);\r\n    print_r($month);\r\n}\r\n\/\/ demo();\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53c3\u8003\u8cc7\u6599 : https:\/\/gist.github.com\/jfcherng\/4eb9c81c95b42a1 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.nickyoo7.com\/?p=275\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008PHP \u8fb2\u66c6\u63db\u7b97\u3009<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-275","post","type-post","status-publish","format-standard","hentry","category-php","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PHP \u8fb2\u66c6\u63db\u7b97 - oo7&#039;s World<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.nickyoo7.com\/?p=275\" \/>\n<meta property=\"og:locale\" content=\"zh_TW\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP \u8fb2\u66c6\u63db\u7b97 - oo7&#039;s World\" \/>\n<meta property=\"og:description\" content=\"\u53c3\u8003\u8cc7\u6599 : https:\/\/gist.github.com\/jfcherng\/4eb9c81c95b42a1 &hellip; \u95b1\u8b80\u5168\u6587\u3008PHP \u8fb2\u66c6\u63db\u7b97\u3009\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.nickyoo7.com\/?p=275\" \/>\n<meta property=\"og:site_name\" content=\"oo7&#039;s World\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-07T07:04:23+00:00\" \/>\n<meta name=\"author\" content=\"oo7\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005:\" \/>\n\t<meta name=\"twitter:data1\" content=\"oo7\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9810\u4f30\u95b1\u8b80\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\u9418\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.nickyoo7.com\/?p=275\",\"url\":\"https:\/\/www.nickyoo7.com\/?p=275\",\"name\":\"PHP \u8fb2\u66c6\u63db\u7b97 - oo7&#039;s World\",\"isPartOf\":{\"@id\":\"https:\/\/www.nickyoo7.com\/#website\"},\"datePublished\":\"2024-06-07T07:04:23+00:00\",\"author\":{\"@id\":\"https:\/\/www.nickyoo7.com\/#\/schema\/person\/2ab2a209159a41a5c551869792fd0367\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.nickyoo7.com\/?p=275#breadcrumb\"},\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.nickyoo7.com\/?p=275\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.nickyoo7.com\/?p=275#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9801\",\"item\":\"https:\/\/www.nickyoo7.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP \u8fb2\u66c6\u63db\u7b97\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.nickyoo7.com\/#website\",\"url\":\"https:\/\/www.nickyoo7.com\/\",\"name\":\"oo7&#039;s World\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.nickyoo7.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-TW\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.nickyoo7.com\/#\/schema\/person\/2ab2a209159a41a5c551869792fd0367\",\"name\":\"oo7\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\/\/www.nickyoo7.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e2ffdb3c64d0daa8a28af5806bcb94e283c27974a48761397038108203287e0d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e2ffdb3c64d0daa8a28af5806bcb94e283c27974a48761397038108203287e0d?s=96&d=mm&r=g\",\"caption\":\"oo7\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP \u8fb2\u66c6\u63db\u7b97 - oo7&#039;s World","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.nickyoo7.com\/?p=275","og_locale":"zh_TW","og_type":"article","og_title":"PHP \u8fb2\u66c6\u63db\u7b97 - oo7&#039;s World","og_description":"\u53c3\u8003\u8cc7\u6599 : https:\/\/gist.github.com\/jfcherng\/4eb9c81c95b42a1 &hellip; \u95b1\u8b80\u5168\u6587\u3008PHP \u8fb2\u66c6\u63db\u7b97\u3009","og_url":"https:\/\/www.nickyoo7.com\/?p=275","og_site_name":"oo7&#039;s World","article_published_time":"2024-06-07T07:04:23+00:00","author":"oo7","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005:":"oo7","\u9810\u4f30\u95b1\u8b80\u6642\u9593":"1 \u5206\u9418"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.nickyoo7.com\/?p=275","url":"https:\/\/www.nickyoo7.com\/?p=275","name":"PHP \u8fb2\u66c6\u63db\u7b97 - oo7&#039;s World","isPartOf":{"@id":"https:\/\/www.nickyoo7.com\/#website"},"datePublished":"2024-06-07T07:04:23+00:00","author":{"@id":"https:\/\/www.nickyoo7.com\/#\/schema\/person\/2ab2a209159a41a5c551869792fd0367"},"breadcrumb":{"@id":"https:\/\/www.nickyoo7.com\/?p=275#breadcrumb"},"inLanguage":"zh-TW","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.nickyoo7.com\/?p=275"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.nickyoo7.com\/?p=275#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9801","item":"https:\/\/www.nickyoo7.com\/"},{"@type":"ListItem","position":2,"name":"PHP \u8fb2\u66c6\u63db\u7b97"}]},{"@type":"WebSite","@id":"https:\/\/www.nickyoo7.com\/#website","url":"https:\/\/www.nickyoo7.com\/","name":"oo7&#039;s World","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.nickyoo7.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-TW"},{"@type":"Person","@id":"https:\/\/www.nickyoo7.com\/#\/schema\/person\/2ab2a209159a41a5c551869792fd0367","name":"oo7","image":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/www.nickyoo7.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e2ffdb3c64d0daa8a28af5806bcb94e283c27974a48761397038108203287e0d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e2ffdb3c64d0daa8a28af5806bcb94e283c27974a48761397038108203287e0d?s=96&d=mm&r=g","caption":"oo7"}}]}},"_links":{"self":[{"href":"https:\/\/www.nickyoo7.com\/index.php?rest_route=\/wp\/v2\/posts\/275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nickyoo7.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nickyoo7.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nickyoo7.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nickyoo7.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=275"}],"version-history":[{"count":1,"href":"https:\/\/www.nickyoo7.com\/index.php?rest_route=\/wp\/v2\/posts\/275\/revisions"}],"predecessor-version":[{"id":276,"href":"https:\/\/www.nickyoo7.com\/index.php?rest_route=\/wp\/v2\/posts\/275\/revisions\/276"}],"wp:attachment":[{"href":"https:\/\/www.nickyoo7.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nickyoo7.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nickyoo7.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}