PHP while 循环是无限的
<?php
//Set up the base vars
$sceneCount=23;
$currentScene=1;
$brainBlownCounter=0;
//Assemble the scenes
while($currentScene <= $sceneCount)
{
$scenes[] = 'Scene '.$currentScene;
}
//Make this film special
array_reverse($scenes);
//Play
$sceneCounter =0;
foreach ($scene as $somethingThatHappened)
{
$sceneCounter++;
$leonardsMemory = $somethingThatHappened;
echo ('We see '.$somethingThatHappened.'<br />');
echo ('Your brain is now '.(($sceneCounter / count($scenes) * 100)).'% blown.<br /><br />';
$leonardsMemory=NULL;
}
//TODO: Remember Stanley Ipkiss
?>
谁能发现这段代码中的任何问题吗?
while 循环没有按应有的方式运行,并且没有任何输出!
谢谢
<?php
//Set up the base vars
$sceneCount=23;
$currentScene=1;
$brainBlownCounter=0;
//Assemble the scenes
while($currentScene <= $sceneCount)
{
$scenes[] = 'Scene '.$currentScene;
}
//Make this film special
array_reverse($scenes);
//Play
$sceneCounter =0;
foreach ($scene as $somethingThatHappened)
{
$sceneCounter++;
$leonardsMemory = $somethingThatHappened;
echo ('We see '.$somethingThatHappened.'<br />');
echo ('Your brain is now '.(($sceneCounter / count($scenes) * 100)).'% blown.<br /><br />';
$leonardsMemory=NULL;
}
//TODO: Remember Stanley Ipkiss
?>
Can anyone spot any problems in this code?
The while loop isnt acting as it should be and nothing gets outputted!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
增加 currentScene 的值
并将
其更改
为
Increment the value of currentScene
and
Change this
To
这:
$currentScene
和$sceneCount
都没有改变。This:
Both
$currentScene
and$sceneCount
are not changed.问题就在这里:
添加一个
$currentScene++
以移动到下一个值。The problem is here:
add a
$currentScene++
to move to the next value.