包括/排除的包括基于可变

包括/排除的包括基于可变

问题描述:

值的索引页的声明,我有这样的:包括/排除的包括基于可变

include "commentformonoff.php"; 

我想修改它,这包括仅做,如果一个变量$countcomments是等于99或更少。如果$countcomments等于100或更多,我想回复一条消息,指出“评论已关闭”。

我该怎么做?

由于提前,

约翰

+0

出于好奇,是一个PHP脚本这个条件直列?如果是这样,那么也许你应该考虑切换到使用模板系统(如smarty,或更多的PHP风格的phpsavant)?这将使这种情况在未来更容易管理。 – Kazar 2010-08-23 17:20:52

if($countcomment < 100) 
{ 
    include "commentformonoff.php"; 
} else { 
    echo "Comments Closed"; 
} 
+1

进一步阅读:http://www.php.net/manual/en/language.operators.php和http://www.php.net/manual/en/language.control-structures.php – 2010-08-23 17:25:54