PHP解析错误?

时间:2011-01-26 17:37:42

标签: php wordpress

我在wordpress网站上尝试使用以下代码时出现解析错误(意外的T_Else)。有什么想法可能是什么?对不起PHP新手,请耐心等待。

<?php 
if (time() >= strtotime('11/28/2011') && time() <= strtotime('12/25/2011')) 
 { include (TEMPLATEPATH . '/stub_s10_Nov28-Dec25.php');
 }
else if (time() >= strtotime('12/26/2011') && time() <= strtotime('01/14/2012'))
 { include (TEMPLATEPATH . '/stub_s11_Dec26-Jan14.php');
 }
else if (time() >= strtotime('01/15/2011') && time() <= strtotime('02/14/2011'))
 { include (TEMPLATEPATH . '/stub_s2_Jan15-Feb14.php');
 } 
else if (time() >= strtotime('02/15/2011') && time() <= strtotime('03/17/2011'))
 { include (TEMPLATEPATH . '/stub_s3_Feb15-Mar17.php');
 }
else if (time() >= strtotime('03/18/2011') && time() <= strtotime('04/30/2011'))
 { include (TEMPLATEPATH . '/stub_s4_Mar18-Apr30.php');

else if (time() >= strtotime('05/01/2011') && time() <= strtotime('05/30/2011'))
 { include (TEMPLATEPATH . '/stub_s5_May01-May30.php');
 }
else if (time() >= strtotime('06/01/2011') && time() <= strtotime('07/04/2011'))
 { include (TEMPLATEPATH . '/stub_s6_Jun01-Jul04.php');
 }
else if (time() >= strtotime('07/05/2011') && time() <= strtotime('08/31/2011'))
 { include (TEMPLATEPATH . '/stub_s7_Jul05-Aug31.php');
 }
else if (time() >= strtotime('09/01/2011') && time() <= strtotime('10/31/2011'))
 { include (TEMPLATEPATH . '/stub_s8_Sep01-Oct31.php');
 }
else if (time() >= strtotime('11/27/2011') && time() <= strtotime('11/27/2011'))
 { include (TEMPLATEPATH . '/stub_s9_Nov01-Nov27.php');
 }
?> 

3 个答案:

答案 0 :(得分:6)

在“'/stub_s4_Mar18-Apr30.php')”行之后有一个缺失的括号,这很可能导致此问题。

顺便提一下,您可能希望将当前时间存储在变量中,而不是重复调用time()函数。我也很想使用require_once,除非你特别不介意包含失败。

答案 1 :(得分:2)

您忘记了第17行的结束}

<?php 
if (time() >= strtotime('11/28/2011') && time() <= strtotime('12/25/2011')) 
 { include (TEMPLATEPATH . '/stub_s10_Nov28-Dec25.php');
 }
else if (time() >= strtotime('12/26/2011') && time() <= strtotime('01/14/2012'))
 { include (TEMPLATEPATH . '/stub_s11_Dec26-Jan14.php');
 }
else if (time() >= strtotime('01/15/2011') && time() <= strtotime('02/14/2011'))
 { include (TEMPLATEPATH . '/stub_s2_Jan15-Feb14.php');
 } 
else if (time() >= strtotime('02/15/2011') && time() <= strtotime('03/17/2011'))
 { include (TEMPLATEPATH . '/stub_s3_Feb15-Mar17.php');
 }
else if (time() >= strtotime('03/18/2011') && time() <= strtotime('04/30/2011'))
 { include (TEMPLATEPATH . '/stub_s4_Mar18-Apr30.php');
 }
else if (time() >= strtotime('05/01/2011') && time() <= strtotime('05/30/2011'))
 { include (TEMPLATEPATH . '/stub_s5_May01-May30.php');
 }
else if (time() >= strtotime('06/01/2011') && time() <= strtotime('07/04/2011'))
 { include (TEMPLATEPATH . '/stub_s6_Jun01-Jul04.php');
 }
else if (time() >= strtotime('07/05/2011') && time() <= strtotime('08/31/2011'))
 { include (TEMPLATEPATH . '/stub_s7_Jul05-Aug31.php');
 }
else if (time() >= strtotime('09/01/2011') && time() <= strtotime('10/31/2011'))
 { include (TEMPLATEPATH . '/stub_s8_Sep01-Oct31.php');
 }
else if (time() >= strtotime('11/27/2011') && time() <= strtotime('11/27/2011'))
 { include (TEMPLATEPATH . '/stub_s9_Nov01-Nov27.php');
 }
?> 

答案 2 :(得分:2)

第五个if区块似乎缺少一个近距离。