{"id":60885,"date":"2025-04-26T09:30:22","date_gmt":"2025-04-26T01:30:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/60885\/"},"modified":"2025-04-26T09:30:22","modified_gmt":"2025-04-26T01:30:22","slug":"zen-cart%e5%9c%a8php5-3%e7%8e%af%e5%a2%83%e4%b8%8b%e5%87%ba%e7%8e%b0%e7%9a%84fatal-error-cannot-r","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/60885\/","title":{"rendered":"Zen Cart\u5728PHP5.3\u73af\u5883\u4e0b\u51fa\u73b0\u7684Fatal error: Cannot r"},"content":{"rendered":"<p> Zen Cart 138 \u5728PHP5.3\u73af\u5883\u4e0b\u51fa\u73b0\u7684Fatal error: Cannot redeclare date_diff() in includes\/functions\/functions_general.php\u9519\u8bef\u7684\u89e3\u51b3\u65b9\u6cd5<\/p>\n<p> \u539f\u56e0\u662f\u5728\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u5df2\u5b58\u5728\u51fd\u6570\uff1adate_diff()\u4e86\uff0c\u6b64\u65f6\uff0c\u6211\u4eec\u9700\u8981\u505a\u5230\u4e0e\u65e7\u7248\u672c\u7684PHP\u517c\u5bb9\uff0c\u5c06Zen Cart\u4e2d\u7684date_diff()\u51fd\u6570\u8fdb\u884c\u4fee\u6539\uff0c\u89e3\u51b3\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p>   &nbsp;  <\/p>\n<pre>\r\nif(function_exists('date_diff') &amp;&amp; phpversion() &gt;= 5.3){\r\n    date_diff(date_create($date1), date_create($date2));\r\n}else{\r\n    function date_diff($date1, $date2) {\r\n        \/\/$date1 today, or any other day\r\n        \/\/$date2 date to check against\r\n        \r\n        $d1 = explode(\"-\", $date1);\r\n        $y1 = $d1[0];\r\n        $m1 = $d1[1];\r\n        $d1 = $d1[2];\r\n        \r\n        $d2 = explode(\"-\", $date2);\r\n        $y2 = $d2[0];\r\n        $m2 = $d2[1];\r\n        $d2 = $d2[2];\r\n        \r\n        $date1_set = mktime(0,0,0, $m1, $d1, $y1);\r\n        $date2_set = mktime(0,0,0, $m2, $d2, $y2);\r\n        \r\n        return(round(($date2_set-$date1_set)\/(60*60*24)));\r\n    }\r\n}<\/pre>\n<p>  &nbsp;   <\/p>\n<p> \u5728\u4e0a\u9762\uff0c\u6211\u4eec\u5bf9date_diff()\u51fd\u6570\u662f\u5426\u5b58\u5728\u8fdb\u884c\u5224\u65ad\uff0c\u5e76\u5224\u65adPHP\u7248\u672c\u53f7\uff0c\u53e6\u5916\uff0c\u4e5f\u53ef\u4ee5\u770b\u5230\u6211\u4eec\u4f7f\u7528\u4e86PHP\u65b0\u7248\u672c\u7684\u51fd \u6570\uff1adate_create()\uff0c\u6839\u636e\u7ed9\u51fa\u7684\u65e5\u671f\u65f6\u95f4\u53c2\u6570\u8fd4\u56de Unix \u65f6\u95f4\u6233\uff0c\u8be6\u7ec6\u8d44\u6599\u53ef\u4ee5\u53c2\u770b\uff1ahttp:\/\/www.php.net\/manual\/en\/function.date-create.php\u3002<br \/> \u53e6\u5916\uff0cPHP5.3\u4e2d\u7684date_diff()\u8be6\u7ec6\u60c5\u51b5\u4e5f\u53ef\u4ee5\u67e5\u770b\uff1ahttp:\/\/www.php.net\/manual\/en\/function.date-diff.php<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Zen Cart 138 \u5728PHP5.3\u73af\u5883\u4e0b\u51fa\u73b0\u7684Fatal error: Cannot redeclare date_diff() in includes\/functions\/functions_general.php\u9519\u8bef\u7684\u89e3\u51b3\u65b9\u6cd5 \u539f\u56e0\u662f\u5728\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u5df2\u5b58\u5728\u51fd\u6570\uff1adate_diff()\u4e86\uff0c\u6b64\u65f6\uff0c\u6211\u4eec\u9700\u8981\u505a\u5230\u4e0e\u65e7\u7248\u672c\u7684PHP\u517c\u5bb9\uff0c\u5c06Zen Cart\u4e2d\u7684date_diff()\u51fd\u6570\u8fdb\u884c\u4fee\u6539\uff0c\u89e3\u51b3\u65b9\u6cd5\u5982\u4e0b\uff1a &nbsp; if(function_exists(&#8216;date_diff&#8217;) &amp;&amp; phpversion() &gt;= 5.3){ date_diff(date_create($date1), date_create($date2)); }else{ function date_diff($date1, $date2) { \/\/$date1 today, or any other day \/\/$date2 date to check against $d1 = explode(&#8220;-&#8220;, $date1); $y1 = $d1[0]; $m1 = $d1[1]; $d1 = $d1[2]; $d2 = explode(&#8220;-&#8220;, $date2); $y2 = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-60885","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=60885"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60885\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=60885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=60885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=60885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}