有人可以在此代码中发现任何明显错误吗?该网站没有加载所以我猜这个问题是在PHP的某个地方。该网站是空白的,您可以找到问题所在的任何信息。这只是一小段代码,但它是包含php的唯一一段代码。
<?php
ini_set('display_errors', 'on');
$dir = "sound";
$bucketsArrayString = "var buckets = [";
if (is_dir($dir))
{
$bucket = "";
$intensity = "";
$position = "";
$distance = "";
echo "var soundTree = \n[";
if ($dh = opendir($dir))
{
for($i = 0; ($file = readdir($dh)) !== false; )
{
if($file[0] != ".")
{
if($i > 0)
{
echo ",";
$bucketsArrayString .= ", ";
}
echo "\n\t[";
$bucketsArrayString .= "'$file'";
$bucket = $file;
$distances = array("close", "medium", "distant");
for($j = 0; $j < count($distances); $j++)
{
if($j > 0)
echo ",";
echo "\n\t\t[";
$distance = $distances[$j];
$positions = array("back", "front", "left", "right");
for($k = 0; $k < count($positions); $k++)
{
$position = $positions[$k];
if($k > 0)
echo ',';
echo "\n\t\t\t[";
$intensities = array("often", "seldom");
for($l = 0; $l < count($intensities); $l++)
{
$intensity = $intensities[$l];
$folder = $dir . "/" . $bucket . "/" . $distance . "/" . $position . "/" . $intensity;
if($l > 0)
echo ',';
echo "\n\t\t\t\t[";
$m = 0;
if ($dirHandle = opendir($folder))
{
while (($fileHandle = readdir($dirHandle)) !== false)
{
if($fileHandle[0] != ".")
{
if($m > 0)
echo ",";
echo "\n\t\t\t\t\t'" . $fileHandle . "'";
$m++;
}
}
echo "\n\t\t\t\t]"
}
echo "\n\t\t\t]";
}
echo "\n\t\t]";
}
echo "\n\t]";
$i++;
}
}
closedir($dh);
$bucketsArrayString .= '];';
}
echo "\n];\n";
}
echo $bucketsArrayString;
?>
答案 0 :(得分:1)
您应该使用:
error_reporting(E_ALL);
ini_set('display_errors', 1);
而不是:
ini_set('display_errors', 'on');
答案 1 :(得分:1)
将第75行更改为此
echo "\n\t\t\t\t]"; // missing semicolon
并在末尾添加}
echo $bucketsArrayString;
} // missing bracket
?>
答案 2 :(得分:0)
试
error_reporting(E_ALL);
ini_set('display_errors', 1);
而不是
ini_set('display_errors', 'on');
然后您将收到所有错误和警告