有谁知道为什么forPHP中的循环没有按预期工作?请检查以下内容:
检查文档和谷歌有关运营商:http://php.net/manual/en/language.operators.increment.php
<?php
$a = "Z";
$b = "AL";
echo $a."<br>".$b."<br>";
for ($x = $a; $x <= $b; $x++) {
echo "The number is: $x <br>";
}
while(true){
if($a == $b)break;
echo $a."<br>";
$a++;
}
?>
Run Code Online (Sandbox Code Playgroud)
该for循环迭代没有,而while环路.预期的输出应该从Z- 迭代- AL,while循环正在执行此操作,但for循环不是迭代.
for循环应该遵循Perl的迭代(http://php.net/manual/en/language.operators.increment.php),但显然说不AL大于Z.
但是,将这些字母转换为数字时,for循环将与整数一起使用.