显示意外”。但我无法找出原因

时间:2019-10-17 04:47:08

标签: php mysql

  

解析错误:语法错误,意外的'‬'(T_STRING)。

虽然我将这行用作前几行。

$past=$row['date'];
$present= date("Y-m-d H:i:s");
$second= strtotime($present) - strtotime($past);
if($second<=60){echo "Just Now";}
elseif($second<=3600){echo round($second/60) ."min";}
elseif($second<=86400){echo round($second/3600) . "hour";}
elseif($second<=604800){echo round($second/86400) . "day";}
elseif($second<=2592000‬){echo round($second/604800) . "week";} //in this line
elseif($second<=31536000‬‬){echo round($second/2592000) . "month";}
else{echo $row['date'];}

1 个答案:

答案 0 :(得分:0)

您的代码中包含一些不可见的unicode字符。您可以尝试使用以下替代方法:

$past = $row['date'];
$present = date("Y-m-d H:i:s");
$second = strtotime($present) - strtotime($past);
if ($second <= 60) {
  echo "Just Now";
} elseif ($second <= 3600) {
  echo round($second / 60) . "min";
} elseif ($second <= 86400) {
  echo round($second / 3600) . "hour";
} elseif ($second <= 604800) {
  echo round($second / 86400) . "day";
} elseif ($second <= 2592000) {
  echo round($second / 604800) . "week";
} elseif ($second <= 31536000) {
  echo round($second / 2592000) . "month";
} else {
  echo $row['date'];
}

一个在2592000之后,另外两个在结束括号前31536000之后。