这是我目前的代码:
$directory = "polls/";
$dir = opendir($directory);
while (($file = readdir($dir)) !== false {
$filename = $directory . $file;
$type = filetype($filename);
if ($type == 'file') {
$contents = file_get_contents($filename);
$items = explode('¬', $contents);
echo '<table width="500" border="1" cellpadding="4">';
foreach ($items as $item) {
echo "<tr><td>$item</td></tr>\n";
}
echo '</table>';
}
}
closedir($dir);
由于某种原因,这一行给了我一个错误:
while (($file = readdir($dir)) !== false {
Parse error: syntax error, unexpected '{' in
答案 0 :(得分:4)
平衡括号:
while (($file = readdir($dir)) !== false) {
答案 1 :(得分:3)
应该是
while (($file = readdir($dir)) !== false) {