嘿,我的代码出现错误,谁能告诉我该如何解决?
注意:使用未定义的常量文件夹-在第74行的C:\ xampp \ htdocs \ a \ gallery.php中假定为“文件夹”
注意:第75行的C:\ xampp \ htdocs \ a \ gallery.php中使用未定义的常量文件夹-假定为“文件夹”
这是相关的部分
$path = "./images/gallery";
$results = scandir($path);
foreach ($results as $result) {
if ($result !== "." and $result !== ".." and $result !== ".DS_Store"){
//only lists the folders we want
$folders[] = $result;
}
}
echo "<h2 id=\"galleryheaders\">";
foreach ($folders as $folder){
echo "<a href=\"gallery.php?folder=$folder\">$folder</a>\n";
}
foreach ($folders as $folder){
echo "<?gallery = . $folder>";
}
echo "</h2>";
if (isset($_GET[folder])) {
$gallery = $_GET[folder];
}else {
$gallery = $folders[0];
};
它特别提到的行是最后两个文件夹
您忘记了字符串周围的引号:
if (isset($_GET[folder])) {
$gallery = $_GET[folder];
}
应该:
if (isset($_GET['folder'])) {
$gallery = $_GET['folder'];
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句