本文介绍了为什么我在FOR语句中不断收到php错误,说出了意外的')'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个HTML 10x10表格,每个单元格都有一个单独的ID和链接。正在复制粘贴和更改的过程中,所以我决定使用PHP,使用我不太熟悉的FOR命令。
I am programming an HTML 10x10 table, Each cell with a separate ID and link. It was taking way to long with copying and pasting and changing so I decided to use PHP, using the FOR command which I am not very familiar with.
我正在使用这个代码:
I am using this code:
<table>
<?php
for ($r=1, $r<10,$r++) {
;echo "<TR>";
for ($d=1, $d<10,$d++) {
echo "<TR id='d" . $d . "r" . $r . "'><a href='javascript: void(0)' onclick='shoot(" . $d . "," . $r . ")'>SHOOT!</a>";
}
echo "<TD>";
}
?>
</table>
PHP说:
PHP is saying:
Parse error: syntax error, unexpected ')', expecting ';' in C:\xampp\htdocs\****\*****\index.php on line 16
我主演了我不希望你看到的stuf。
i starred out the stuf I do not want you to see.
我使用的是Windows 7,具有版本1.7 .3
I am using Windows 7 with XAMPP version 1.7.3
推荐答案
使用分号(; 中为
循环(而不是逗号)。
Use a semicolon (;
) in your for
loop (instead of a comma).
请缩进你的代码,它更容易阅读......
And please indent your code, it makes it a lot easier to read...
类似于这样:
for ($r=1; $r<10; $r++) {
echo "<TR>";
for ($d=1; $d<10; $d++) {
echo "<TR id='d".$d."r".$r."'><a href='javascript: void(0)' onclick='"
."shoot(".$d.",".$r.")'>SHOOT!</a>";
}
echo "<TD>";
}
这篇关于为什么我在FOR语句中不断收到php错误,说出了意外的')'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!