我有这个问题:
我有2个php文件> index.php和control.php.
在control.php中有一个名为"$ControlNumber"
的变量,它的默认值是10,还有一个名为"$Name"
的变量
在index.php里面,我有一个条件为($ControlNumber < 10)
的while,每执行一次,$ControlNumber
的值就增加1。
代码的末尾我用"$Name"
的名字做了一个div,但这不起作用。
我用href链接这样执行代码:
<?php
if ($_GET['run_func'] == 'yes') {
include "control.php";
$ControlNumber--;
} else {
echo '<a href="?run_func=yes">Press here 2 add a player</a>';
}
?>
while内代码:
<?php
include "control.php";
while($ControlNumber < 10) {
$ControlNumber++;
echo '<div id="Linea1" style="background-color#751313; color:white; font- size:150%;";>' . $Name .'</div>';
$Name = "Used";
}
?>
"Control.php"代码
<?php
$ControlNumber;
$ControlNumber = 10;
$Name = "John";
?>
我在编写这段代码时尝试了很多不同的选项,但"Text/Echo"
不工作或出现。
这不起作用,因为var $ControlNumber = 10
while
条件只在这个变量小于10时运行
尝试声明这个变量$controlNumber = 0
可能是这个工作^^
$ControlNumber的初始值为10。之后你的条件说
while( $ControlNumber < 10){
// code here
}
这意味着——
while( 10 < 10){
// code here
}
总是假的。