我正在尝试从用户读取一个数字并将其分配给php变量。由于JavaScript变量为字符串格式,因此我使用了强制for循环将其隐式化为ineger。但是它没有打印任何输出。请向我解释我在代码中做错了什么....
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
var t=prompt("Number of Test Cases");
</script>
</head>
<body>
</body>
</html>
<?php
$t="<script>document.write(t)</script>";
for($i=0;$i<(int)$t;$i++){
echo $i;
}
?>
我尝试不强制转换变量。但是结果是一样的。
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
var t=prompt("Number of Test Cases");
</script>
</head>
<body>
</body>
</html>
<?php
$t="<script>document.write(t)</script>";
for($i=0;$i<$t;$i++){
echo $i;
}
?>