Parse error: syntax error, unexpected '–' (T_STRING) in C:\xampp\htdocs\*****\*****\functions.php on line 187
第187行,位于下面代码框中的第9行。 $zjd = (int)((1461...
这是打印Hijri日历的功能,它取决于月亮,它与公历依赖于太阳不同。 Date();
函数打印出格里高利日期,并且Hijri日期没有任何函数(也称为伊斯兰日历)。这两者之间存在差异。例如,格里高利历中的年份是365.25,但是在Hijri日历中是354.367。还有几个月......等等。
我做了一个函数将Gregorian转换为Hijri,但它并不准确,所以我搜索了一个。 我找到了很多准确的,但用JavaScript编写。并且刚刚找到了这篇用PHP编写的精品。
我试图联系作家关于这个问题,但他没有回应。发布于2011年。
function hijriCal(){
$theDate = getdate();
$wday = $theDate['wday'];
$hr = $theDate['mday'];
$theMonth = $theDate['mon'];
$theYear = $theDate['year'];
if (($theYear > 1582) || (($theYear == 1582) && ($theMonth > 10)) || (($theYear == 1582) && ($theMonth == 10) && ($hr > 14))) {
$zjd = (int)((1461 * ($theYear + 4800 + (int)(($theMonth – 14) / 12))) / 4) + (int)((367 * ($theMonth – 2 – 12 * ((int)(($theMonth – 14) / 12)))) / 12) – (int)((3 * (int)((($theYear + 4900 + (int)(($theMonth – 14) / 12)) / 100))) / 4) + $hr – 32075;
} else {
$zjd = 367 * $theYear – (int)((7 * ($theYear + 5001 + (int)(($theMonth – 9) / 7))) / 4) + (int)((275 * $theMonth) / 9) + $hr + 1729777;
}
答案 0 :(得分:3)
在–
(ascii:161)而不是-
(ascii:45)上似乎是一个错误的字符。
以下是替换版本。
function hijriCal(){
$theDate = getdate();
$wday = $theDate['wday'];
$hr = $theDate['mday'];
$theMonth = $theDate['mon'];
$theYear = $theDate['year'];
if (($theYear > 1582) || (($theYear == 1582) && ($theMonth > 10)) || (($theYear == 1582) && ($theMonth == 10) && ($hr > 14))) {
$zjd = (int)((1461 * ($theYear + 4800 + (int)(($theMonth - 14) / 12))) / 4) + (int)((367 * ($theMonth - 2 - 12 * ((int)(($theMonth - 14) / 12)))) / 12) - (int)((3 * (int)((($theYear + 4900 + (int)(($theMonth - 14) / 12)) / 100))) / 4) + $hr - 32075;
} else {
$zjd = 367 * $theYear - (int)((7 * ($theYear + 5001 + (int)(($theMonth - 9) / 7))) / 4) + (int)((275 * $theMonth) / 9) + $hr + 1729777;
}