我认为我做的事情从根本上说是错误的。这是我的代码
的index.php
<?php
if(isset($_POST['a'])){
$action = $_POST['a'];
} else if(isset($_GET['a'])){
$action = $_GET['a'];
} else {
$action = "home";
}
if($action == "home"){
$frontImages = glob('assets/images/frontpage/*');
include_once 'home.php';
}
?>
我在var_dump($frontImages)
内部homp.php
(btw显示正常)但我得到$frontImages
是一个未定义的变量。 index.php
文件和home.php
文件都在根文件夹中,这是路径目录的图像:
所以不确定我在这里做错了什么。
答案 0 :(得分:0)
使用
<?php
if(isset($_REQUEST['a'])) {
$action = $_GET['a'];
} else {
$action = "home";
}
if($action == "home"){
while($acImg = glob('assets/images/frontpage/*')) {
$frontImages[] = $acImg;
}
include_once 'home.php';
}
?>
现在你有一个数组,但我的工作原理