我正试图让这段脚本发挥作用,但它一直在中消亡
$currentdays = intval(date("t"));
echo $currentdays; //echoes 30 as we're in April
$i = 1;
while ($i <= $currentdays){
echo $day;
}
它不断地死去,没有任何错误。我觉得时机不对,但肯定要慢慢来。
您需要递增$i
。1将始终小于30,从而创建一个无限循环。
$currentdays = intval(date("t"));
$i = 0;
while ($i++ < $currentdays){
echo $i; // outputs 1, 2, 3.. 30
}
$i
从未更改。试试这个:
$currentdays = intval(date("t"));
echo $currentdays; //echoes 30 as we're in April
$i = 1;
while ($i++ < $currentdays){
echo $i;
}
在回显$day之后,您永远不会增加$i。这将进入一个无限循环。